include("../conn.php");
$url=$_GET['url'];//URL地址
$uid=$_GET['uid'];//id值
function get_center($url_id,$uid){
// $c//从缓存中获取内容
$url=$url_id;
$id=$uid;
$c//吧缓存的内容赋值给一个变量
ob_end_clean();//关闭缓存并清空
/***缓存结束***/
file_put_contents("../".$id.".html", $content);
}
$sql="select * from article where id=".$uid."";
$query=mysql_query($sql);
$rs=mysql_fetch_array($query);
if($rs["url"]==''){
get_center($url,$uid);
$sql="UPDATE article SET url='localhost/weizhuan/".$uid.".html' WHERE id = ".$uid."";
//$sql="UPDATE article SET FirstName = 'Fred' WHERE LastName = 'Wilson' ";
@mysql_query($sql) or die("sql have err");
echo "<script> alert('成功生成html文件'); window.location.href='all_article.php'</script>";
}else{
get_center($url,$uid);
$sql="UPDATE article SET url='localhost/weizhuan/".$uid.".html' WHERE id = ".$uid."";
//$sql="UPDATE article SET FirstName = 'Fred' WHERE LastName = 'Wilson' ";
@mysql_query($sql) or die("sql have err");
echo "<script> alert('HTML已存在,原文件已覆盖。'); window.location.href='all_article.php'</script>";
}
?>
以上就介绍了 php页面静态化 获取页面缓存生成HTML页面,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。