Home  >  Article  >  Backend Development  >  PHP generates static page html page code_PHP tutorial

PHP generates static page html page code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:39:50714browse

  1. header(Content-type:text/html;charset=utf-8);
  2. if( !function_exists(file_get_contents)){ //If the system does not have the file_get_contents() function
  3. function file_get_contents($file){ //Write the file_get_contents() function yourself
  4. $fp = fopen($file ,r);
  5. $content = fread($fp,filesize($file));
  6. fclose($fp);
  7. return $content;
  8. }
  9. }
  10. $tmp_file = template.html; //Template file
  11. $content = file_get_contents($tmp_file); //Get template file content
  12. $title = title; //The value to be replaced by the template variable title
  13. $text = text; //The value to be replaced by the template variable text
  14. $content = str_replace( <{title}>,$title,$content); //Replace template variable title
  15. $content = str_replace(<{text}>,$text,$content); //Replace Template variable text
  16. //echo $content; //Display the replaced template file content
  17. MakeHtml(news.html,$content);//Write the generated static file content Go to news.html file
  18. echo View file;
  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)){ //If the system does not have the file_get_contents() function function file_get_contents($file){ //Write it yourself...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn