Easy PHP AOP

Source: Internet
Author: User
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/
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.