I am doing a PHP tutorial and I found this code
Class Insurance
{
function clsName()
{
echo get_class($this)."\n";
}
}
$cl = new Insurance();
$cl->clsName();
Insurance::clsName();
here function clsName()
is accessed without creating an instance of Insuarance
Insurance::clsName();
But from the definition
The Scope Resolution Operator (also called Paamayim Nekudotayim) or in simpler terms, the double colon, is a token that allows access to static, constant, and overridden properties or methods of a class.
When referencing these items from outside the class definition, use the name of the class.
http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php
I searched in web but coul not find a good explanation why this code is working? please explain.