下面介绍一下怎么实现生成静态页面
template.html 模版页面
<html> <head> <title><{title}></title> //到时候需要替换的标题 </head> <body> <center><{content}></center> </body> </html> php文件 <?php $template = file_get_contents('./template.html');//获取模版内容 $html = 'out.html'; $output = str_replace('<{title}>', $title, $template);//字符串替换 $output = str_replace('<{content}>', $section, $output); file_put_contents($html, $output);//文件写入函数 ?>