【www.gdgbn.com--页面特效】
代码如下 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}>",$title,$content); //替换模板变量title
$content = str_replace("<{text}>",$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------<{title}>
这是模板变量text------<{text}>