欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP 五 入门 读、写文本文件(二)

程序员文章站 2022-04-18 13:31:31
...
PHP 5 入门 读、写文本文件(二)

??

===============

写文件

===============

$realFiePath = "D:/test.txt";

$fileContent = "Test 2011 03 12.";

?

$file = fopen($realFiePath, 'wb');

fwrite($file, $fileContent );

fclose($file);

?

?

===============

读文件

===============

$realFiePath = "D:/test.txt";

$size = intval(sprintf("%u", filesize($realFiePath)));
$handle = fopen($realFiePath, "rb");
$fileContent = "";
??while (!feof($handle)) {
????? $fileContent .= fread($handle, $size);
????? ob_flush();
??? ??flush();
??}
??fclose($handle);

?

echo $fileContent ;

PHP 五 入门 读、写文本文件(二)

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频