|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-05-08 10:37 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 23:00:01 2025 UTC |
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