当前位置:Gxlcms > PHP教程 > PHP读写文件生成HTML的代码举例

PHP读写文件生成HTML的代码举例

时间:2021-07-01 10:21:17 帮助过:24人阅读

  1. //生成HTML
  2. $countfile="template.html";
  3. $num=file_get_contents($countfile);
  4. echo $num;
  5. $num=str_replace("|*|*|PAGE_TITLE|*|*|","myhome",$num);
  6. $path="template.html";
  7. $handle=fopen($path,"w"); //写入方式打开新闻路径
  8. fwrite($handle,$num); //把刚才替换的内容写进生成的HTML文件
  9. fclose($handle);
  10. ?>

说明: file_get_contents -- 将整个文件读入一个字符串 file -- 把整个文件读入一个数组中

详细参考: php file_get_contents抓取页面信息的代码 php file_get_contents函数抓取页面信息的代码 php file_get_contents函数代理获取远程页面的代码 php file_get_contents函数的使用问题

人气教程排行