ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-dev
php-dev
#44944 [Opn->WFx]: PHP Scope resolution operator
by derick other posts by this author
May 8 2008 3:37AM messages near this date
#44944 [NEW]: PHP Scope resolution operator | #44943 [NEW]: Failed opening required
ID:               44944
 Updated by:       derick@[...].net
 Reported By:      som dot guha at yahoo dot com
-Status:           Open
+Status:           Wont fix
 Bug Type:         Class/Object related
 Operating System: linux
 PHP Version:      5.2.6
 New Comment:

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



Previous Comments:
------------------------------------------------------------------------

[2008-05-08 10:12:51] som dot guha at yahoo dot com

Description:
------------
I am using php 5.2.5 version. I was testing the functionality of the
scope resolution operator. In php.net 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:
MyClass::showMyName();
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";
   }
}

MyClass::showMyName();

Expected result:
----------------
Should generate an error.

Actual result:
--------------
My Name


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44944&edit=1
Thread:
Som Dot Guha At Yahoo Dot Com
derick

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved