/**
* proxy模式
*
* 为其他对象提供一个代理以控制这个对象的访问
*
*/
interface Proxy
{
public function request();
public function display();
}
class RealSubject
{
public function request()
{
echo "RealSubject request<br/>";
}
public function display()
{
echo "RealSubject display<br/>";
}
}
class ProxySubject
{
private $_subject = null;
public function __construct()
{
$this->_subject =new RealSubject();
}
public function request()
{
$this->_subject->request();
}
public function display()
{
$this->_subject->display();
}
}
$objProxy=new ProxySubject();
$objProxy->request();
$objProxy->display();
参考文章 https://wenku.baidu.com/view/b4c78b4702768e9951e738fb.html
网友评论