|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
刚开始写页面程序,调试完书中的例子。然后就可以尝试编写留言板了,法式|静态 PHP代码:--------------------------------------------------------------------------------
/*
版权一切:日出西方XP
2004.7.17
*/
function CreateShtml()
{
ob_start(array("callback_CreateShtml","callback_GoToShtml"));
}
function callback_CreateShtml($buffer)
{
$page = intval(@$_REQUEST["page"]);
$fileName = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . "/" . basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm";
$fp = fopen($fileName,"wb");
fwrite($fp,$buffer);
fclose($fp);
return $buffer;
}
function callback_GoToShtml($buffer)
{
$page = intval(@$_REQUEST["page"]);
$fileName = basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm";
header("location:" . $fileName);
return $buffer;
}
function GoToShtml()
{
$page = intval(@$_REQUEST["page"]);
$fileName = basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm";
if(file_exists($fileName))
header("location:" . $fileName);
}
function DeleteShtml($fileName=NULL)
{
if(is_null($fileName))
$fileName = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF'];
if($fileName[0]=="/")
$fileName = $_SERVER['DOCUMENT_ROOT'] . $fileName;
$path = dirname($fileName);
$dir = dir($path);
$patten = "/^" . basename($fileName, ".php") . "(_[0-9]+)?.htm/";
while(($entry = $dir->read())!==false)
{
if(is_file($path . "/" .$entry) && preg_match($patten,$entry))
unlink ($path . "/" . $entry);
}
}
终于学会把表单的数据插入数据库,然后显示出来了,应该说一个程序的雏形已经诞生了。 |
|