Maison  >  Article  >  développement back-end  >  php生成静态页html页面代码_PHP教程

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

WBOY
WBOYoriginal
2016-07-13 17:39:50677parcourir

  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){ //自己写...
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn