php生成静态页html页面代码
Release: 2016-06-13 10:38:38
Original
945 people have browsed it
-
- header(Content-type:text/html;charset=utf-8);
- if(!function_exists(file_get_contents)){ //如果系统没有file_get_contents()函数
- function file_get_contents($file){ //自己写file_get_contents()函数
- $fp = fopen($file,r);
- $content = fread($fp,filesize($file));
- fclose($fp);
- return $content;
- }
- }
- $tmp_file = template.html; //模板文件
- $content = file_get_contents($tmp_file); //获得模板文件内容
- $title = title; //模板变量title要替换的值
- $text = text; //模板变量text要替换的值
- $content = str_replace(,$title,$content); //替换模板变量title
- $content = str_replace(,$text,$content); //替换模板变量text
- //echo $content; //显示替换后的模板文件内容
- MakeHtml(news.html,$content);//写入生成后的静态文件内容到news.html文件
- echo 查看文件;
- function MakeHtml($file,$content){
- $fp = fopen($file,w);
- fwrite($fp,$content);
- fclose($fp);
- }
- ?>
-
Statement of this Website
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
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31