<pre name="code" class="php"><?php
$myfiletoread = fopen("txt/readme.txt","r") or die("Unable to open file!");
$myfileread = fread($myfiletoread,"20");
$myfiletowrite =fopen("txt/writeme.txt","a+") or die("Unable to open file!");
fwrite($myfiletowrite, $myfileread);
fclose($myfiletoread);
fclose($myfiletowrite);
?>
实现了从一个文件读取了二十个字节。
ok,如果只是需要读取整个文件的内容作为字符串,官方建议用另外一个性能好得多的函数:
file_get_contents(path,include_path,