Rumah  >  Artikel  >  pembangunan bahagian belakang  >  php生成静态页html页面代码_PHP教程

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

WBOY
WBOYasal
2016-07-13 17:39:50676semak imbas

  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){ //自己写...
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn