最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php生成静态页面代码
时间:2022-06-24 18:30:01 编辑:袖梨 来源:一聚教程网
| 代码如下 | 复制代码 |
| 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); } ?> |
|
//template.html
| 代码如下 | 复制代码 |
|
这是模板变量title------ 这是模板变量text------ |
|
相关文章
- jm天堂网页版官方登录入口-jm天堂网页版直接登录入口 12-14
- 蝉妈妈网页版直达入口-蝉妈妈app官方正版入口在哪 12-14
- 豆包AI智能在线网页解析神器-豆包AI智能在线会议纪要生成助手 12-14
- 小红书Web官网登录入口-小红书官方网页版一键登录 12-14
- 苍云阅读app如何快速找到目录-目录入口位置 12-14
- 苹果ID登录官网入口 - 苹果Apple ID账户登录页面一键直达 12-14