Heim > php教程 > PHP源码 > 我在想练习PHP

我在想练习PHP

PHP中文网
Freigeben: 2016-05-25 17:06:12
Original
1249 Leute haben es durchsucht

[PHP]代码    

<?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();
?>
Nach dem Login kopieren

                   

                   

Verwandte Etiketten:
php
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Aktuelle Ausgaben
PHP-Datenerfassung?
Aus 1970-01-01 08:00:00
0
0
0
PHP-Erweiterung intl
Aus 1970-01-01 08:00:00
0
0
0
Wie man PHP gut lernt
Aus 1970-01-01 08:00:00
0
0
0
Mehrere PHP-Versionen
Aus 1970-01-01 08:00:00
0
0
0
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage