Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
PHP Scope Resolution Operator (::)
Introduction
In PHP, the double colon :: is defined as Scope Resolution Operator. It used when when we want to access constants, properties and methods defined at class level. When referring to these items outside class definition, name of class is used along with scope resolution operator. This operator is also called Paamayim Nekudotayim, which in Hebrew means double colon.
Syntax
Inside class
To access class level items inside any method, keyword - self is used
In child class
If a parent class method overridden by a child class and you need to call the corresponding parent method, it must be prefixed with parent keyword and scope resolution operator
Example
";
}
}
class myclass extends testclass{
public function sayhello(){
parent::sayhello();
echo "Hello PHP";
}
}
$obj=new myclass();
$obj->sayhello();
?>
Output
This will produce following output −
Hello World Hello PHP
Advertisements
