PHP scope qualifier double colon: usage. The dual-colon operator refers to the scope limitation operator ScopeResolutionOperator, which can access static, const, and attributes and methods that are rewritten in the class. Use the class name for calling when it is used outside the class definition. The dual-colon Operator is the Scope limitation Operator. Scope Resolution Operator can access static, const, and attributes and methods that are rewritten in the class.
Use the class name for calling when it is used outside the class definition. In PHP 5.3.0, you can use variables instead of class names.
Program List: use variables to define external access in the class
Program List: used outside the class definition ::
Program running result:
Fruit Color Red
Program List: call the parent method
showColor();?>
Program running result:
Fruit::showColor() Apple::showColor()
Program List: Use the scope qualifier
color; } } class Banana { public $color; public function __construct() { $this->color = "Banana is yellow"; } public function GetColor() { return Apple::showColor(); } } $banana = new Banana; echo $banana->GetColor();?>
Program running result:
Banana is yellow
Program List: call the method of the base class
Program running result:
show color
Resolution Operator can access static, const, and attributes and methods that are rewritten in class. If it is used outside the class definition, use the class name to call it ....