php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31023 $var = "myClass::myMethod"; echo $var(); does generate Error
Submitted: 2004-12-08 15:06 UTC Modified: 2005-01-13 17:07 UTC
From: jan dot reitz at lanxess dot com Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5.0.3RC1 OS: Windows 2000
Private report: No CVE-ID: None
 [2004-12-08 15:06 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-12 01:19 UTC] 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.
 [2005-01-13 17:07 UTC] jan dot reitz at lanxess dot com
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
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 14:01:34 2024 UTC