class Delegate{ public $object = null; public $functionname = ""; public function __construct(&$object, $functionname) { $this->object = &$object; $this->functionname = $functionname; } public function Invoke($value1, $value2 = null) { return call_user_func(array($this->object, $this->functionname), $value1, $value2); }}
class Ebc{ public $SendDelegate = null; public function Receive($value) { $this->Send($value); } protected function Send($value) { if (!is_null($this->SendDelegate)) return $this->SendDelegate->Invoke($value); }}class FinalDestination{ public function Receive($value) { echo $value; }}
$final = new FinalDestination();$ebc = new Ebc();$ebc->SendDelegate = new Delegate($final, "Receive");$ebc->Receive("Hallo Welt");