国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

用Php模擬asp.net的頁面模型

2024-05-04 23:03:56
字體:
來源:轉載
供稿:網友
  • 本文來源于網頁設計愛好者web開發社區http://www.html.org.cn收集整理,歡迎訪問。
  • 用php模擬asp.net是不大可能的,特別是對于php這樣的對面向對象支持不完整的動態語言來講,更是很大的困難.在這些說模擬是說可以由這個例子來理解asp.net的運行機制(又說深了,他僅僅是一個模以而以) .代碼很簡單,無需細說,本測試在win2000,iis5,php 4.4.0上運行通過

    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();
    ?>

    發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 麟游县| 布尔津县| 金溪县| 尼勒克县| 金湖县| 谷城县| 苗栗县| 延寿县| 西城区| 岫岩| 固镇县| 观塘区| 公主岭市| 永胜县| 商洛市| 延川县| 攀枝花市| 祁阳县| 龙海市| 左云县| 松潘县| 克什克腾旗| 江门市| 密云县| 双鸭山市| 平顶山市| 隆德县| 平顺县| 武威市| 平罗县| 锡林浩特市| 合山市| 伊金霍洛旗| 乐安县| 财经| 浦县| 南华县| 延庆县| 特克斯县| 卓资县| 成武县|