<?php
classClassOne {
functioncallClassOne() {
print"In Class One";
}
}
classClassOneDelegator {
private$targets;
function__construct() {
$this->target [] = newClassOne ();
}
function__call($name, $args) {
foreach( $this->target as$obj) {
$r= newReflectionClass ( $obj);
if($method= $r->getMethod ( $name)) {
if($method->isPublic () && ! $method->isAbstract ()) {
return$method->invoke ( $obj, $args);
}
}
}
}
}
$obj= newClassOneDelegator ();
$obj->callClassOne();
結果:In Class One