-
- 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 the file_get_contents() function yourself
- $fp = fopen($file ,r);
- $content = fread($fp,filesize($file));
- fclose($fp);
- return $content;
- }
- }
- $tmp_file = template.html; //Template file
- $content = file_get_contents($tmp_file); //Get template file content
- $title = title; //The value to be replaced by the template variable title
- $text = text; //The value to be replaced by the template variable text
- $content = str_replace( <{title}>,$title,$content); //Replace template variable title
- $content = str_replace(<{text}>,$text,$content); //Replace Template variable text
- //echo $content; //Display the replaced template file content
- MakeHtml(news.html,$content);//Write the generated static file content Go to news.html file
- echo View file;
- function MakeHtml($file,$ content){
- $fp = fopen($file,w);
- fwrite($fp,$content);
- fclose($fp);
- }
- ?>
-
http://www.bkjia.com/PHPjc/486247.htmlwww.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...