1.使用投影操作授权模式classClassOne{functioncallClassOne(){print"inclassone\n";}}classClassTwo{functioncallClassTwo(){print"inclasstwo";}}classClassOneDelgater{private$target;函数__construct(){$this->target[]=newClassOne();}functionaddObject($obj){$this->target[]=$obj;}function__call($name,$args){foreach($this->targetas$obj){$r=newReflectionClass($obj);尝试{if($method=$r->getMethod($name)){if($method->isPublic()){return$method->invoke($obj,$args);}}}catch(Exception$e){//打印$e->getMessage();}}}}$obj=newClassOneDelgater();$obj->addObject(newClassTwo());//var_dump($obj->target);$obj->callClassOne();$obj->callClassTwo();结果是在classoneinclass22.函数、类、变量PHP遇到未定义的变量或常量会继续运行,但一旦遇到未定义的函数或类就会终止执行。课堂上有一个特例。如果用户定义了__autoload函数,当他在PHP中调用一个未定义的类时,会通过__autoload返回该类的定义,使用新加载的类不会报错
