#31023 [Bgs->Csd]: $var = "myClass::myMethod"; echo $var(); does generate Error

From: Date: Thu, 13 Jan 2005 16:07:54 +0000
Subject: #31023 [Bgs->Csd]: $var = "myClass::myMethod"; echo $var(); does generate Error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-72073@lists.php.net to get a copy of this message
ID: 31023 User updated by: jan dot reitz at lanxess dot com Reported By: jan dot reitz at lanxess dot com -Status: Bogus +Status: Closed Bug Type: Class/Object related Operating System: Windows 2000 PHP Version: 5.0.3RC1 New Comment: thank you !!! i hadn't thought that call_user_func_array wouldn't throw errors.... in fact i don't understand why it works with call_user_func_array and not with call_user_func... but thats okay to me :D Previous Comments: ------------------------------------------------------------------------ [2005-01-12 01:19:19] tony2001@php.net It was never supposed to work, so this is not a bug. Use call_user_func_array(Array('MyClass','myMethod'),Array(&$var)); instead. ------------------------------------------------------------------------ [2004-12-08 15:06:22] jan dot reitz at lanxess dot com Description: ------------ i have defined a method in 'myClass' named 'myMethod' and it can be called statically. i cant use call_user_func() because i need to pass a variable by reference and since call_user_func() is a function itself i cant get the variable passed (if i add the "&" to the variable in call_user_func i get a "calltime-pass-by-reference" error in php5, but it works for now) tried with 4.3.8 and 5.0.3RC1 Reproduce code: --------------- Generates Error: <? $meth = 'myMethod'; is_callable(array('myClass',$meth),null,$callname); echo $callname($variable); ?> Works: <? echo myClass::myMethod($variable); ?> Expected result: ---------------- myClass::myMethod() should be called Actual result: -------------- PHP Fatal error: Call to undefined function myClass::myMethod() in XXX on line XXX ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31023&edit=1

« previous php.bugs (#72073) next »