page.php
<?php/********************************************************************************Sinoprise Function Classes*CopyRight(c):2006 Sinoprise Technology Lab**Unit Name: page.php*func: *Crate:Shuguang Yin 2006-07-15*******************************************************************************/ class SFC_Page {
//环境变量 /*var $Server; var $Session; var $QueryString; var $Post; var $Cookie; var $Files; var $Env;*/
//页面控制属性 var $EnableViewState; //页面属性 var $CharSet;//页面字符集 var $PageTitle;//页面的标题 var $PageStyle;//页面的风格
function SFC_Page() {
/*if (strcmp(substr(PHP_VERSION,0,1),4)>=0){
$Server = $_SERVER; $Session = $_SESSION; $QueryString = $_GET; $Post = $_POST; $Cookie = $_COOKIE; $Files = $_FILES; $Env = $_ENV;
}else{
global $HTTP_SERVER_VARS,$HTTP_GET_VARS,$HTTP_POST_VARS,$HTTP_COOKIE_VARS,$HTTP_POST_FILES ; global $HTTP_ENV_VARS,$HTTP_SESSION_VARS; $Server = $HTTP_SERVER_VARS; $Session = $HTTP_SESSION_VARS; $QueryString = $HTTP_GET_VARS; $Post = $HTTP_POST_VARS; $Cookie = $HTTP_COOKIE_VARS; $Files = $HTTP_POST_FILES; $Env = $HTTP_ENV_VARS;
}*/
$this->EnableViewState = false;
} //发生在服务器状态还原之前 function PageInit() { }
//发生在服务器状态还原之后,但在服务器端事件之前 function PageLoad() { }
//发生在激发服务器端事件之后,但在生成任何东西之前 function PagePreRender() { }
//发生在生成页面之时 function PageRender() { }
//发生在网页生成完成之后 function PageUnLoad() { }
//显示输出 function Display() {
$this->PageInit(); if ($this->EnableViewState){ $this->DeCodeViewState(); } $this->PageLoad(); $this->PagePreRender(); echo "<html><title>".$this->PageTitle."</title>"; echo "<META http-equiv=Content-Type content=\"text/html; charset=".$this->CharSet."\">"; echo "<body ".$this->PageStyle.">"; echo "<form name=\"SFC_WebForm\" id=\"SFC_WebForm\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">"; $this->PageRender(); if ($this->EnableViewState){ $this->EnCodeViewState(); } echo "</form></body></html>"; $this->PageUnLoad();
} //判断是第一次打开还是post function IsPostBack() { } //对ViewState进行编码 function EnCodeViewState() { echo "<input type=\"hidden\" name=\"SFC_ViewState\" id=\"SFC_ViewState\" "; echo "Value=\"".base64_encode(serialize($this))."\""; echo ">"; } //对ViewState进行解码 function DeCodeViewState() { if (isset($_POST['SFC_ViewState'])){ $this = unserialize(base64_decode($_POST['SFC_ViewState'])); } } }?>
页面文件,php.php
<? require_once('page.php'); class PhpTest extends SFC_Page { var $conut; function PhpTest() { } //发生在服务器状态还原之前 function PageInit() { } //发生在服务器状态还原之后,但在服务器端事件之前 function PageLoad() { } //发生在激发服务器端事件之后,但在生成任何东西之前 function PagePreRender() { } //发生在生成页面之时 function PageRender() { echo ++$this->conut; //echo serialize($this); echo "<br>"; echo "<input type=submit value=\"OOKK\" name=hello>"; } //发生在网页生成完成之后 function PageUnLoad() { } } $cls = new PhpTest(); $cls->CharSet="gb2312"; $cls->PageTitle="页面的标题"; $cls->EnableViewState=true; $cls->Display(); ?>
Trackback: <A href="http://tb.blog.csdn.net/TrackBack.aspx?PostId=932084">http://tb.blog.csdn.net/TrackBack.aspx?PostId=932084</A>