xxxxxxxxxx
/*
There are several scenarios in which you might want
to make your constructor private.
The common reason is that in some cases,
you don't want outside code to call your constructor directly,
but force it to use another method to get an instance of your class.
Singleton pattern
You only ever want a single instance of your class to exist:
*/
class Singleton
{
private static $instance = null;
private function __construct()
{
}
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
}