php文件操作 读取写入操作

读取写入操作


$file ='./hello.txt';//文件路径
$handle = fopen($file,'r');//打开,r 方式为只读
$content = fread($handle,filesize($file));//读取原本内容
$content = 'Hello World'.$content;//拼接
fclose($handle);//关闭
$handle = fopen($file,'w');//重新打开,w写入,原本内容被清除
fwrite($handle,$content);//写入
fclose($handle);//关闭


猜你喜欢

转载自blog.csdn.net/qq_39940866/article/details/78349386