- <?php
- class Test{
- private $arr =array('x'=>null,'y'=>null);
- function display($count){
- for($i=1;$i<$count;$i++){
- print "hello".$i.'<br>';
- }
- return $count;
- }
- }
- class TestDelegator{
- private $obj;
- function __construct(){
- $this->obj=new Test();
- }
- function __call($method,$args){
- return call_user_func_array(array($this->obj,$method),$args);
- }
- }
- $obj = new TestDelegator();
- //用TestDelegator的实例调用Test的方法法
- print $obj->display(10);
- ?>
__call()重载,简单的授权
最新推荐文章于 2023-09-18 17:26:44 发布