当前位置:首页 > PHP教程 > PHP基础知识

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

<?php 
//生成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 -- 把整个文件读入一个数组中
【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!