
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>比较file_put_contents()函数和fopen()、fwrite()、fclose()的优越性</title>
</head>
<body>
<?php
$filepath = "text.txt";
$str = "乘风破浪会有时 直挂云帆济沧海<br>";
echo "用fwrite函数写入文件:";
$fopen = fopen($filepath,'wb') or die('文件不存在');
fwrite($fopen,$str);
fclose($fopen);
readfile($filepath);
echo "<p>用file_put_contents函数写入文件:";
file_put_contents($filepath,$str);
readfile($filepath);
?>
</body>
</html>



