首頁 > php教程 > PHP源码 > 主體

PHP 事件驱动程序

PHP中文网
發布: 2016-05-26 08:18:44
原創
1182 人瀏覽過

1.class.Dispatcher.php

handle=$event_handle;
    }
     
    function handle_the_event(){
        $name="handler_$this->handle";
        if(class_exists("$name")){
            $handler_obj=new $name($this->handle);
            $response=$handler_obj->secure_handler();
            return $response;
        }else{
            echo "I can't handle this!";
        }
    }
}
?>

Secure,Event Driven Record Viewer!
handle_the_event(); } $_SESSION['name']="Wangzy"; if(isset($_POST['event'])) handle(); ?>
登入後複製

2.class.Handler_Event.php

handle=$event_handle;
    }
     
    function handled_event(){
        echo "The event, $this->handle, is now handled.
It is ,I promise!

Your records are as follows:

"; $id=parent::dbconn(); $result=mysql_query("select * from table01",$id); while($row=mysql_fetch_array($result)){ echo "Numbers:".$row['number']."\tName:".$row['name']."
"; } } function secure_handler(){ if($_SESSION['name']=="Wangzy"){ $this->handled_event(); }else{ echo "Sorry {$_SESSION['name']} you are not authorized!"; } } } //Edit Event class Handler_Edit extends Event_Handler{ private $handle; function __construct($event_handle){ $this->handle=$event_handle; } function handled_event(){ echo "This is event $this->handle, which is now handled -no kidding!
"; } function secure_handler(){ $this->handled_event(); } }
登入後複製
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!