While learning about design patterns I have come across the singleton pattern:
class Singleton
{
private static $instance = null;
private function __construct()
{
}
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
}
I'm having a hard time understanding what the constructor does in this circumstance. There isn't any code being executed between the braces? How does this work? Thanks.