Use Php to simulate the asp.net page model

Source: Internet
Author: User
Using Php to simulate the asp.net page model and reading the Php to simulate the asp.net page model is unlikely to simulate asp.net With php, it is especially difficult for php to support an incomplete dynamic language for object-oriented systems. in these cases, simulation means that we can use this example to understand the operating mechanism of asp.net. (Furthermore, it is just a model.) "> <LINKhref =" h

It is unlikely to use php to simulate asp.net. especially for dynamic languages such as php that do not have full object-oriented support, it is very difficult. in these cases, the simulation can be used to understand the operating mechanism of asp.net. (Furthermore, it is just a model ). the code is very simple. you do not need to elaborate on it. this test passes through win2000, iis5, and php 4.4.0.

Page. php

/*************************************** ****************************************
* Sinoprise Function Classes
* CopyRight (c): 2006 Sinoprise Technology Lab
*
* Unit Name: page. php
* Func:
* Crate: Shuguang Yin 2006-07-15
**************************************** ***************************************/
Class SFC_Page
{

// Environment variable
/* Var $ Server;
Var $ Session;
Var $ QueryString;
Var $ Post;
Var $ Cookie;
Var $ Files;
Var $ Env ;*/

// Page control attributes
Var $ EnableViewState;

// Page properties
Var $ CharSet; // page character set
Var $ PageTitle; // The page title
Var $ PageStyle; // page style





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;


}
// Occurs before the server status is restored
Function PageInit ()
{
}


// Occurs after the server state is restored, but before the server event
Function PageLoad ()
{
}


// Occurs after a server event is triggered, but before anything is generated
Function PagePreRender ()
{
}


// When the page is generated
Function PageRender ()
{
}


// After the webpage is generated
Function PageUnLoad ()
{
}


// Display the output
Function Display ()
{


$ This-> PageInit ();
If ($ this-> EnableViewState ){
$ This-> DeCodeViewState ();
}
$ This-> PageLoad ();
$ This-> PagePreRender ();
Echo"". $ This-> PageTitle ."";
Echo" ";
Echo"PageStyle. "> ";
Echo"";
$ This-> PageUnLoad ();


}

// Determine whether it is the first time to open or post
Function IsPostBack ()
{

}
// Encode ViewState
Function EnCodeViewState ()
{
Echo"Echo "Value = \" ". base64_encode (serialize ($ this ))."\"";
Echo "> ";
}
// Decodes ViewState
Function DeCodeViewState ()
{
If (isset ($ _ POST ['sfc _ viewstate']) {
$ This = unserialize (base64_decode ($ _ POST ['sfc _ viewstate']);
}
}
}
?>

 

Page file, php. php

Require_once ('Page. php ');
 
Class PhpTest extends SFC_Page
{
Var $ conut;

Function PhpTest ()
{
 
}
// Occurs before the server status is restored
Function PageInit ()
{
}

// Occurs after the server state is restored, but before the server event
Function PageLoad ()
{
}

// Occurs after a server event is triggered, but before anything is generated
Function PagePreRender ()
{
}

// When the page is generated
Function PageRender ()
{
Echo ++ $ this-> conut;
// Echo serialize ($ this );
Echo"
";
Echo"";
}

// After the webpage is generated
Function PageUnLoad ()
{
}
}
 
$ Cls = new PhpTest ();
$ Cls-> CharSet = "gb2312 ";
$ Cls-> PageTitle = "page title ";
$ Cls-> EnableViewState = true;
$ Cls-> Display ();
?>

Trackback: http://tb.blog.csdn.net/TrackBack.aspx? PostId = 932084

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.