十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
本篇文章为大家展示了php中怎么生成静态页面,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

add.php
添加新闻
config.php
DB_class.php
host = $host;
$this->uname = $uname;
$this->port = $port;
$this->pwd = $pwd;
$this->db = $db;
mysql_connect($host,$uname,$pwd);
mysql_select_db($this->db);
}
public static function Instance()
{
if(Db::$instance==null){
include 'config.php';
return Db::$instance = new DB(HOST, USER, PWD, PORT, DB);
}
else
return Db::$instance;
}
public function query($sql)
{
mysql_query("SET NAMES UTF8");
$query = mysql_query($sql) or die($sql." error");
if(!$query) return false;
else return $query;
}
public function getAll($sql)
{
$query = $this->query($sql);
if($query)
{
while($ret = mysql_fetch_assoc($query))
{
$result[] = $ret;
}
}
return $result;
}
}
?>doadd.php
query($sql);
$fp=fopen("model.htm","r");$str=fread($fp,filesize("model.htm"));$str=str_replace("{title}",$title,$str);$str=str_replace("{content}",$content,$str);fclose($fp);
$dir = dirname($filename);if(!is_dir($dir)){ mkdir($dir);}
$handle=fopen($filename,"w"); fwrite($handle,$str); fclose($handle);
echo "查看刚才添加的新闻";echo "添加新闻";?>model.htm
{title}
{content}