Scope Resolution operator in PHP Last Updated : 21 Jul, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. PHP <?php class democlass { const PI = 3.14; } echo democlass::PI; ?> Output: 3.14 Example 2: Three special keywords self, parent, and static are used to access properties or methods from inside the class definition. PHP <?php // Declaring parent class class demo{ public static $bar=10; public static function func(){ echo static::$bar."\n"; } } // Declaring child class class Child extends demo{ public static $bar=20; } // Calling for demo's version of func() demo::func(); // Calling for child's version of func() Child::func(); ?> Output: 10 20 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. PHP <?php class demo{ public function myfunc() { echo "myfunc() of parent class\n "; } } class child extends demo { public function myfunc(){ // Calling parent's version // of myfunc() method parent::myfunc(); echo "myfunc() of child class"; } } $class = new child; $class -> myfunc() ?> Output: myfunc() of parent class myfunc() of child class Comment More infoAdvertise with us Next Article PHP | Ternary Operator V vanshikagoyal43 Follow Improve Article Tags : Web Technologies PHP PHP Programs Write From Home PHP-Operators +1 More Similar Reads PHP | Ternary Operator If-else and Switch cases are used to evaluate conditions and decide the flow of a program. The ternary operator is a shortcut operator used for shortening the conditional statements. ternary operator: The ternary operator (?:) is a conditional operator used to perform a simple comparison or check on 3 min read When to use self over $this in PHP ? The self and this are two different operators which are used to represent current class and current object respectively. self is used to access static or class variables or methods and this is used to access non-static or object variables or methods. So use self when there is a need to access someth 2 min read Double not (!!) operator in PHP The "NOT NOT" operator or Double not(!!) operator in PHP simply returns the truth value of the variable or expression. To explain in very simple terms, the first not operator(!) negates the expression. The second not operator(!) again negates the expression resulting the true value which was present 2 min read What is the use of â=>â symbol in PHP ? The '=>' symbol is used to assign key value pairs in an array. The value of left side is called key and the value of right side is called value of key. It is mostly used in associative array. Syntax: key => value Example 1: PHP program to create associative array using '=>' symbol. php <?ph 2 min read Ternary operator vs Null coalescing operator in PHP Ternary Operator Ternary operator is the conditional operator which helps to cut the number of lines in the coding while performing comparisons and conditionals. It is an alternative method of using if else and nested if else statements. The order of execution is from left to right. It is absolutely 3 min read PHP | Common terminology in OOP Object Oriented Programming is a very important concept for programmers to solve real-life problems. This article explaining the concept of object-oriented programming and its features. Object: Everything in this world is surrounded with objects. Table, chair, monitor, cellphone everything is an obj 14 min read Like