note 109073 modified in language.types.callable by danbrown

From: Date: Tue, 19 Jun 2012 13:45:37 +0000
Subject: note 109073 modified in language.types.callable by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-188694@lists.php.net to get a copy of this message
You can also use the $this variable to specify a callback:&#13;&#10;&#13;&#10;&#60;?php&#13;&#10;class MyClass {&#13;&#10;&#13;&#10; public $property = &#39;Hello World!&#39;;&#13;&#10;&#13;&#10; public function MyMethod()&#13;&#10; {&#13;&#10; call_user_func(array($this, &#39;myCallbackMethod&#39;));&#13;&#10; }&#13;&#10;&#13;&#10; public function MyCallbackMethod()&#13;&#10; {&#13;&#10; echo $this-&#62;property;&#13;&#10; }&#13;&#10;&#13;&#10;}&#13;&#10;?&#62; --was-- You can also use the $this variable to specify a callback: <?php class MyClass { public $property = 'Hello World!'; public function MyMethod() { call_user_func(array($this, 'myCallbackMethod')); } public function MyCallbackMethod() { echo $this->property; } } http://php.net/manual/en/language.types.callable.php

« previous php.notes (#188694) next »