php html smarty,PHP如何用Smarty实现html静态化页面

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 PHP如何用Smarty实现HTML静态化页面?以下是具体代码,具体如下: ?php require_once(“./config/config.php”); ob_start(); $id=$_GET[id]; $sql=“select * from table_name where id='$id‘”; $res

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

PHP如何用Smarty实现HTML静态化页面?以下是具体代码,具体如下:

require_once(“./config/config.php”);

ob_start();

$id=$_GET[id];

$sql=“select * from table_name 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; //返回文件名

}

?>

最后在将生成的静态页面发布到web上.

test.jsp?url=http%3A%2F%2Fwww.chinaitlab.com%2Fcms%2Fimages%2Flogo14.gif&refer=http%3A%2F%2FLinux.chinaitlab.com%2FPHP%2F908655.html

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值