#20204 [Opn->Csd]: $var_classname::function(); returns a parse error. You need to use eval().
| From: | pollita@php.net | Date: | Tue, 28 Jan 2003 21:07:10 +0000 |
| Subject: | #20204 [Opn->Csd]: $var_classname::function(); returns a parse error. You need to use eval(). | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969351389@lists.php.net to get a copy of this message | ||
ID: 20204
Updated by: pollita@php.net
Reported By: nih@phlux.co.uk
-Status: Open
+Status: Closed
-Bug Type: Feature/Change Request
+Bug Type: Documentation problem
Operating System: Linux
PHP Version: 4.2.3
New Comment:
As you state, this calling convention is not supported. The reason
relates to how the Zend engine parses PHP syntax and will not change in
the forseeable future. However, there is cleaner way to accomplish
what you're attempting without using eval().
Try:
return call_user_func(array($varclassname,'function'));
I notice that the documentation for call_user_func fails to note the
ability to call static class methods in this way(changing category to
documentation problem) and have added an additional paragraph and
explanation explaining this.
Previous Comments:
------------------------------------------------------------------------
[2002-10-31 15:37:27] nih@phlux.co.uk
The comma `:' in the first line of code is supposed to be a double
comma `::'
------------------------------------------------------------------------
[2002-10-31 15:34:41] nih@phlux.co.uk
Using
$var_classname:function();
throws up a parse error. This was probably not a feature intended to be
included rather than a bug. Currently I have a workaround using this:
print eval("return ".$var_classname."::function();");
Would like to see it implemented in a future version if possible :)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20204&edit=1