The Scope resolution operator (::) allows access to static, constant properties or methods of a class. When referring to a class outside the class definition, we must use class name.
Syntax for scope resolution operator
<?php
class className
{
const CONS = "value here...";
}
$var = 'className';
echo $var::CONS; // access the const under class
?>
When an extending class overrides a method, it does not necessarily call its parent class. It is up to the extended class whether to call the parent class or not. The example below refers to it:
Example with extending class overriding a method
Comments
No comments have been made yet.
Please login to leave a comment. Login now