note 44761 added to function.call-user-func

From: Date: Sun, 15 Aug 2004 20:11:04 +0000
Subject: note 44761 added to function.call-user-func
Groups: php.notes 
Request: Send a blank email to php-notes+get-74737@lists.php.net to get a copy of this message
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()" ?> ---- Manual Page -- http://www.php.net/manual/en/function.call-user-func.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44761 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44761&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44761&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#74737) next »