public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new self(); } return self::$instance; }
/** * @return Bootstrap */ public static function singleton() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
/** * Singleton * If instance of class doesn't exist, autoload application models and create new instance of class * If instance of class does exist, return instance * @return object */ public static function singleton() { if (!isset(self::$instance)) { foreach (glob("application/models/*.php") as $filename) { include $filename; } $className = __CLASS__; self::$instance = new $className(); } return self::$instance; }
public static function getInstance() { if (empty(self::$instance)) { self::$instance = new Bootstrap(); } return self::$instance; }
<?php include "../core/Bootstrap.php"; Bootstrap::instance();