最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHP中运用Smarty实现HTML静态化
时间:2022-07-02 10:46:01 编辑:袖梨 来源:一聚教程网
require_once("./config/config.php教程");
ob_start();
$id=$_GET[id];
$sql="select * from test where id='$id'";
$result=mysql_query($sql);
$rs=mysql_fetch_object($result);
$smarty->assign("showtitle",$rs->title);
$smarty->assign("showcontent",$rs->content);
$smarty->display("content.html");
$this_my_f= ob_get_contents();
ob_end_clean();
$filename = "$id.html";
tohtmlfile_cjjer($filename,$this_my_f);
// 文件生成函数
function tohtmlfile_cjjer($file_cjjer_name,$file_cjjer_content)
{
if (is_file ($file_cjjer_name)){
@unlink ($file_cjjer_name); //存在,就删除
}
$cjjer_handle = fopen ($file_cjjer_name,"w"); //创建文件
if (!is_writable ($file_cjjer_name)){ //判断写权限
return false;
}
if (!fwrite ($cjjer_handle,$file_cjjer_content)){
return false;
}
fclose ($cjjer_handle); //关闭指针
return $file_cjjer_name; //返回文件名
}
相关文章
- 菜鸡梦想家在哪里预约 预约操作方法介绍 12-30
- 菜鸡梦想家预约奖励有哪些 预约奖励内容及领取方法介绍 12-30
- 菜鸡梦想家什么时候公测 公测时间及预约福利介绍 12-30
- 燕云十六声周年庆限定外观是什么 周年庆限定外观一览 12-30
- 燕云十六声周年庆兑换码是什么 周年庆兑换码最新分享 12-30
- 战双帕弥什布偶熊骇影辅助机怎么选 布偶熊骇影辅助机推荐 12-30