>  기사  >  php教程  >  php生成静态页html页面代码

php生成静态页html页面代码

WBOY
WBOY원래의
2016-06-13 10:38:38896검색

  1. header(Content-type:text/html;charset=utf-8);
  2. if(!function_exists(file_get_contents)){ //如果系统没有file_get_contents()函数
  3. function file_get_contents($file){ //自己写file_get_contents()函数
  4. $fp = fopen($file,r);
  5. $content = fread($fp,filesize($file));
  6. fclose($fp);
  7. return $content;
  8. }
  9. }
  10. $tmp_file = template.html; //模板文件
  11. $content = file_get_contents($tmp_file); //获得模板文件内容
  12. $title = title; //模板变量title要替换的值
  13. $text = text; //模板变量text要替换的值
  14. $content = str_replace(,$title,$content); //替换模板变量title
  15. $content = str_replace(,$text,$content); //替换模板变量text
  16. //echo $content; //显示替换后的模板文件内容
  17. MakeHtml(news.html,$content);//写入生成后的静态文件内容到news.html文件
  18. echo 查看文件;
  19. function MakeHtml($file,$content){
  20. $fp = fopen($file,w);
  21. fwrite($fp,$content);
  22. fclose($fp);
  23. }
  24. ?>

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.