<?php
class prototype {
function __get($key){
$this->property__=array_merge(self::$__property,$this->property__);
return $this->property__[$key]; //实例动态添加
}
function __set($key,$value){ //实例获取
$this->property__=array_merge(self::$__property,$this->property__);
$this->property__[$key]=$value;
return $this;
}
public static function __callstatic($methodname,$arg){
$method=self::$__property[$methodname];
$method();
}
public function __call($methodname,$arg){
$method=$this->property__[$methodname];
$method($arg);
return $this;
}
public static function _set($key,$value){
return self::$__property[$key]=$value;
}
public function set_($key,$value){
$this->property__=array_merge(self::$__property,$this->property__);//
$this->property__[$key]=$value;
return $this;
}
public static function _get($key){
return self::$__property[$key];
}
public static $__property=array();
public $property__=array();
}
class user extends prototype{
public $_queue=array();
function _before($functionname,$beforefunction,$beforeaction=null,$action=null){
if(!empty($beforeaction)){
$this->$beforefunction=$beforeaction;
}
if(!empty($action)){
$this->$functionname=$action;
}
$pos=array_search($functionname,$this->_queue);
if(!($pos===false)){
array_splice($this->_queue,$pos,0,$beforefunction);
}else{
array_unshift($this->_queue,$beforefunction,$functionname);
}
return $this;
}
function _after($functionname,$afterfunction,$afteraction=null,$action=null){
if(!empty($afteraction)){
$this->$afterfunction=$afteraction;
}
if(!empty($action)){
$this->$functionname=$action;
}
$pos=array_search($functionname,$this->_queue);
if(!($pos===false)){
array_splice($this->_queue,$pos+1,0,$afterfunction);
}else{
array_push($this->_queue,$functionname,$afterfunction);
}
return $this;
}
function queue(){
$queue=$this->_queue;
foreach( $queue as $work){
$this->$work();
}
}
}
$a=new user();
$a->_after("turnon","input",function(){echo "输入用户名,";},function(){echo "开机,O(∩_∩)O哈哈~" ;});
$a->_after("input","inputpassword",function(){echo "输入密码,";});
$a->_after("inputpassword","click",function(){echo "点击登录按钮";});
$a->_before("click","verif",function(){echo "输入验证码,";});
$a->queue();
?>
PHP是程式语言、MySQL是资料库,要学好任何一种都不是件容易的事,而我们,还要将它做出成果出来!很难吗?不会的!有好的方法、好的流程,其实是可以很轻松的学会,并且应用在网页上的。 书里所介绍的是观念、流程,一个步骤一个步骤依照需求,就可以做出我们要的结果,不怕做不出来,希望藉由这本书,可以让你将这些观念实现在你的网站里。 PHP & MySQL的学习,只要有正确的观念、正确
442
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号