This is the project I am reading from . https://github.com/sasatomislav/PHP5-OOP-Cart
class Cart
{
<snip>
private function __construct() {}
/**
* Fetch Cart instance
*
* @return Cart
*/
public function getInstance()
{
if (NULL === self::$_instance) {
self::$_instance = new self;
}
return self::$_instance;
}
}
<snip>
// initialize shopping cart
// note that Cart implements Singleton pattern
$cart = Cart::getInstance();
How is getInstance which is not a static method, called using :: .
the double colon, is a token that allows access to static, constant, and overridden properties or methods of a class.
getInstance is neither static or constant or being overriden here..
Further if I make getInstance static, it makes noe difference to the code.
Confused. Explain please.