Proxy

来源:互联网 发布:lua for windows 64 编辑:程序博客网 时间:2024/05/14 10:47
<?php
//The essence of the Proxy is to hold a reference to the subject object in an instance variable and to
//pass method calls on the Proxy class down to the subject.
//Lastly, your Proxy class must provide all of the public methods your subject class supports
class Subject {
    function someMethon(){
        echo __METHOD__ . " called in " . __CLASS__;
    }
}


class  ProxySubject {
    public $subject ;
    function __construct(){
        $this->subject = new Subject();
    }
    function someMethon(){
        $this->subject->someMethon();
    }
}


$proxy = new ProxySubject();
$proxy->someMethon();
原创粉丝点击