This article mainly introduces the PHP proxy model detailed and the case, the interested friend's reference, hoped to be helpful to everybody.
The code is as follows:
<?php//Proxy mode index.php header ("Content-type:text/html;charset=utf-8"); Require_once "proxy.php"; Proxy object $obj = new Proxy ("professional thing"); Show $obj->show (); [PHP] View plain copy<?php//proxy interface interface Iproxy {function Show (); }//Real object Class profession implements Iproxy {/** * Private professional thing * @var String */Private $Thing S /** * Construction Method * @access public * @param string $things professional thing * * function __construct ($things) { $this->things = $things; }/** * How to display real objects * @access public */function show () {echo "professional talent do {$this->things}" ; }}//proxy object Class Proxy implements Iproxy {/** * Private real object variable * @var Object */Private $ Pro; /** * Construction Method * @access public * @param string $things professional thing * * function __construct ($things) { $this->pro = new Profession ($things); }/** * Proxy Object Display method * @access public */function show () {$this->pro->show (); } }
Output structure:
Professional talent to do professional things
Related recommendations:
A detailed description of the proxy mode of JS design mode
Proxy mode for JavaScript
The practice of proxy mode and read-write separation of PHP design idea