php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33463 Unexpected Paamayim Nekudotayim in Dynamic Static Method Call
Submitted: 2005-06-24 12:26 UTC Modified: 2005-06-24 12:44 UTC
Votes:12
Avg. Score:4.4 ± 1.2
Reproduced:10 of 11 (90.9%)
Same Version:3 (30.0%)
Same OS:0 (0.0%)
From: etienne at actrix dot co dot nz Assigned:
Status: Wont fix Package: Class/Object related
PHP Version: 5.0.4 OS: Windows XP Pro
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: etienne at actrix dot co dot nz
New email:
PHP Version: OS:

 

 [2005-06-24 12:26 UTC] etienne at actrix dot co dot nz
Description:
------------
Basically, a call to a static class method produces a parse error. Unexpected Paamayim Nekudotayim (::).

This sort of coding works on normal method calls, and object instantiation.

For example, the following works fine:

$name = "ClassName";
$instance = new $name();

^^ will create a new instance of ClassName;

or

public function method() {
//some code
}

$methodName = "method";
$methodName();

^^ will run method().

Reproduce code:
---------------
class ClassName {

public static function staticClassMethod() {
//some code
}

}

$name = "ClassName";
$name::staticClassMethod();


Expected result:
----------------
I expected php to call the method "staticClassMethod".

Actual result:
--------------
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM ...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-24 12:44 UTC] tony2001@php.net
Use call_user_func() for that.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 05:01:28 2025 UTC