/** * Статическая функция, которая возвращает * экземпляр класса или создает новый при * необходимости * * @return SingletonTest */ public static function getInstance() { // проверяем актуальность экземпляра if (self::$_instance === null) { // создаем новый экземпляр self::$_instance = new self(); } // возвращаем созданный или существующий экземпляр return self::$_instance; }
/** * @return SingletonTest */ public static function getInstance() { // We need to check if the $instance is set??? if (!isset(self::$instance)) { // If it isn't set, then we need to set it, to ??? self::$instance = new self(); } // return the instantiated, singleton, instance return self::$instance; }