note 34474 added to function.call-user-func
| From: | Carl at rack1 dot php dot net | Date: | Mon, 28 Jul 2003 16:53:18 +0000 |
| Subject: | note 34474 added to function.call-user-func | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52857@lists.php.net to get a copy of this message | ||
I had a problem where I wanted to parameterize a callback. The end called was in an external class,
but I needed to save some state for the callback that didn't make sense to keep in the original
object, as it might change from call to call...
class foo
{
function foo()
{
$str = "Hello There";
$str2 = "Carl";
$that =& new holder($str);
call_user_func(array(&$that, 'callback'), $str2);
}
}
class holder
{
function holder($aParam)
{
$this->param = $aParam;
}
function callback($aStr)
{
echo "A=$this->param, B=$aStr\n";
}
}
----
Manual Page -- http://www.php.net/manual/en/function.call-user-func.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34474
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34474&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34474&report=yes