note 45230 added to function.call-user-func

From: Date: Mon, 30 Aug 2004 17:13:56 +0000
Subject: note 45230 added to function.call-user-func
Groups: php.notes 
Request: Send a blank email to php-notes+get-75682@lists.php.net to get a copy of this message
Yes... We see it again - Stupidity of PHP language. Passing arguments by reference is deprecated so the solution postead @ 15-Aug-2004 10:11 is invalid (because deprecated). You could try using something like <?php $reference($string); ?> however, then $reference would be converted into a string 'Array' and en error would be triggered because function array does not exist (note: array() is a language structure). The real sollution is as fallows: <?php class foo { function bar(&$param) { $param = "foo::bar()"; } } $foo = new foo(); $reference = array($foo,'bar'); $string = "I've been untouched"; call_user_func_array($reference, array(&$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+45230 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45230&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45230&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#75682) next »