|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44944 PHP Scope resolution operator
Submitted: 2008-05-08 10:12 UTC Modified: 2008-05-08 10:37 UTC
Avg. Score:3.5 ± 0.5
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: som dot guha at yahoo dot com Assigned:
Status: Wont fix Package: Class/Object related
PHP Version: 5.2.6 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: som dot guha at yahoo dot com
New email:
PHP Version: OS:


 [2008-05-08 10:12 UTC] som dot guha at yahoo dot com
I am using php 5.2.5 version. I was testing the functionality of the scope resolution operator. In site it stated that "The Scope Resolution Operator (also called Paamayim Nekudotayim) or in simpler terms, the double colon, is a token that allows access to static, constant, and overridden members or methods of a class.". Now if you check my following code:

class MyClass{
   public function showMyName(){
     echo "My Name";

From the above code, I am able to access the showMyName() method without creating any object, with the help of scope resolution operator, like:
If you check my code you can see that I have never declared the method as a static method. Show how I am able to access that method with the scope resolution operator. I think this is violating the OOPs rule.


Reproduce code:
class MyClass{
   public function showMyName(){
     echo "My Name";


Expected result:
Should generate an error.

Actual result:
My Name


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-08 10:37 UTC]
I agree with you, but it was decided not to make this a fatal error. If you have E_STRICT turned on (which I think you should), you will see this:

Strict standards: Non-static method MyClass::showMyName() should not be called statically in /home/derick/- on line 8

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Aug 02 23:01:23 2021 UTC