|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #31318 Static method invocation with classname in a variable
Submitted: 2004-12-28 10:35 UTC Modified: 2007-09-27 08:25 UTC
Avg. Score:4.6 ± 0.7
Reproduced:14 of 14 (100.0%)
Same Version:3 (21.4%)
Same OS:9 (64.3%)
From: Assigned: colder
Status: Closed Package: Feature/Change Request
PHP Version: 5CVS-2004-12-28 (dev) OS: Irrelevant
Private report: No CVE-ID:
 [2004-12-28 10:35 UTC]
Static members of a class should be accessible even if the classname is stored in a variable.

Reproduce code:
class Foo {
    public static function bar() {
        print 'Foo::bar()';

$class = 'Foo';

Expected result:

Actual result:
Parse error: parse error in D:\foo.php on line 9


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-02 11:59 UTC]
 [2005-05-10 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-01-31 15:49 UTC] markus at cultcom dot de
This still does'nt work and I would realy like to see this working because it is very ugly to use
eval("return $className::method();") as a workaround...
 [2006-01-31 17:51 UTC] phoeniks at nm dot ru
$result = call_user_func(array($class, 'bar'));
 [2007-08-13 15:51 UTC] l dot lucioni at communicationvalley dot it
but still exists. why is it not classified as a bug?
 [2007-08-13 16:05 UTC]
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at

Fixed in PHP5.2.4RC1
 [2007-09-27 08:25 UTC]
(Was reverted prior to 5.2.4 but committed to 5.3.0)
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Mon Oct 05 01:01:33 2015 UTC