Simple PHP AOP
In contrast, feeling is easier to understand than spring AOP.
'; }}///Business logic Class wrapper classes class AOP {private $instance; Public function __construct ($instance) {$this->instance = $instance; The Public Function __call ($method, $argument) {if (! method_exists ($this->instance, $method)) { throw new Exception (' Undefined method: '. $method); } echo ' Permission check
'; $callBack = Array ($this->instance, $method); $return = Call_user_func_array ($callBack, $argument); Echo ' Log record
'; return $return; }}//Factory method class Factory {public Function getbizinstance () {return new AOP (new BIZ ()); }}//Client invokes the demo header ("content-type:text/html; CHARSET=GBK "); try {$obj = Factory::getbizinstance (); $obj->foobar (); } catch (Exception $e) {echo ' Caught Exception: ', $e->getmessage ();}?> screen display: Permission Check business logic logging
http://blog.163.com/lgh_2002/blog/static/44017526201052563459/