php生成静态页html页面代码_PHP教程

WBOY
发布: 2016-07-13 17:39:50
原创
687 人浏览过

  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. ?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486247.htmlTechArticle?php header(Content-type:text/html;charset=utf-8); if(!function_exists(file_get_contents)){ //如果系统没有file_get_contents()函数 function file_get_contents($file){ //自己写...
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!