note 44761 deleted from function.call-user-func by aidan
| From: | aidan@php.net | Date: | Tue, 31 Aug 2004 06:54:43 +0000 |
| Subject: | note 44761 deleted from function.call-user-func by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75713@lists.php.net to get a copy of this message | ||
Note Submitter: php at koert dot bitfactory dot i dot dislike dot spam dot nl
----
Calling functions with a reference to a parameter is possible, but the parameter should be passed as
a reference as well. This is a bit different from the direct way of calling.
<?php
class foo
{
function bar( &$param )
{
$param = "foo::bar()";
}
}
$foo = new foo();
$reference = array($foo,'bar');
$string = "I've been untouched";
// compare to $foo->bar( $string )
call_user_func($reference,$string);
echo $string; // outputs "I've been untouched"
call_user_func($reference, &$string);
echo $string; // outputs "foo::bar()"
?>