final class Factory
{
public static function Instance()
{
static $instance = null;
if ($instance === null) {
$instance = new Factory();
}
return $instance;
}
private function __construct()
{
echo "Factory";
}
}
$fact1 = Factory::instance();
$fact2 = Factory::instance();
$fact3 = new Factory();
/*
run:
Factory
Fatal error: Call to private Factory::__construct() from invalid context in
C:\xampp\htdocs\allonpage.com\test.php on line 23
*/