Blogger Information
Blog 20
fans 588
comment 0
visits 16521
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP文件写入和读取
韦小宝的博客
Original
1284 people have browsed it

PHP写入文件

fh 是一个变量,为资源类型的变量 fh 是一个变量,为资源类型的变量

打开本来下的msg文本

a 是让每次写的留言跟在之前的留言后,为了不覆盖前面的

$fh = fopen('./msg.txt', 'a');

往文件里写东西,沿着资源往里写

fwrite($fh, 'asdasdas')//'这里是写入的内容';

关闭资源

fclose($fh);

PHP文件读取 打开文件

$fh = fopen('./msg.txt','r'); //r 是只读取

从文件指针中读入一行并解析 CSV 字段 并显示

var_dump(fgetcsv($fh)) ;

关闭文件

fclose($fh);


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post