The scope resolution operator also known as Paamayim Nekudotayim or more commonly known as the double colon is a token that allows access to static, constant, and overridden properties or methods of a class.
It is used to refer to blocks or codes in context to classes, objects, etc. An identifier is used with the scope resolution operator. The most common example of the application of the scope resolution operator in PHP is to access the properties and methods of the class.
The following examples show the usage of the scope resolution operator in various scenarios.
Example 1: This type of definition is used while defining constants within a class.
Examlpe 2: Three special keywords self, parent, and static are used to access properties or methods from inside the class definition.
Example 3: When an extending class overrides its parent’s function, the compiler calls the child class’s version of the method but it is up to the child class to call its parent’s version of the method.
myfunc() of parent class myfunc() of child class
- Scope of Variable in R
- Ternary operator vs Null coalescing operator in PHP
- PHP | $ vs $$ operator
- 'AND' vs '&&' as operator in PHP
- Double not (!!) operator in PHP
- What is the difference between the | and || or operator in php?
- PHP | Ternary Operator
- PHP 7 | Spaceship Operator
- How to instantiate Struct Pointer Address Operator in Golang?
- How to add a PHP page to WordPress?
- PHPUnit assertIsObject() Funtion
- Difference between PHP and DENO
- What are the best input sanitizing functions in PHP ?
- jQuery Jcrop Plugin
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.