search
Homephp教程php手册用Php模拟asp.net的页面模型

用php模拟asp.net是不大可能的,特别是对于php这样的对面向对象支持不完整的动态语言来讲,更是很大的困难.在这些说模拟是说可以由这个例子来理解asp.net的运行机制(又说深了,他仅仅是一个模以而以) .代码很简单,无需细说,本测试在win2000,iis5,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
 {
     
     //环境变量
     /*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 "

".$this->PageTitle."";
   echo "";
   echo "PageStyle.">";
   echo "
";
   $this->PageRender();
   if ($this->EnableViewState){
                    $this->EnCodeViewState();
   }
   echo "
";     
   $this->PageUnLoad();

  }
 
  //判断是第一次打开还是post
  function IsPostBack()
  {
  
  }
  //对ViewState进行编码
  function EnCodeViewState()
  {
                     echo "                    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 "
";
             echo "";
  }
 
  //发生在网页生成完成之后
  function PageUnLoad()
  {
  } 
 }
 
 $cls = new PhpTest();
 $cls->CharSet="gb2312";
 $cls->PageTitle="页面的标题";
 $cls->EnableViewState=true;
 $cls->Display();
?>



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.