Home > php教程 > php手册 > body text

php入门学习知识点六 PHP文件的读写操作代码_php入门_脚本之家

WBOY
Release: 2016-06-06 20:37:57
Original
1035 people have browsed it

php入门学习知识点六 PHP文件的读写操作代码,读取文件内容 可以用以下两个函数进行操作 fread,file_get_contents

代码如下:
//打开文件
$fp=fopen('tmp.html', 'r');
//读取文件内容 可以用以下两个函数进行操作 fread,file_get_contents
$str=fread($fp, filesize('tmp.html')); //filesize为获取文件大小
$content=file_get_contents('tmp.html');
//写文件
$news=fopen('news.html', 'w');
fwrite($news, $content);
//关闭文件流
fclose($fp);
fclose($news);
echo $content;
?>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template