Home > php教程 > php手册 > PHP读写文件的方法(生成HTML)

PHP读写文件的方法(生成HTML)

WBOY
Release: 2016-06-13 12:36:05
Original
1171 people have browsed it

//生成HTML 
$countfile="template.html"; 
$num=file_get_contents($countfile); 
echo $num; 
$num=str_replace("|*|*|PAGE_TITLE|*|*|","myhome",$num); 
$path="template.html"; 
$handle=fopen($path,"w"); //写入方式打开新闻路径 
fwrite($handle,$num); //把刚才替换的内容写进生成的HTML文件 
fclose($handle); 
?> 
file_get_contents -- 将整个文件读入一个字符串
file -- 把整个文件读入一个数组中

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