Re: is there a static constructor?
| From: | Darren Karstens | Date: | Thu, 31 Mar 2011 10:12:37 +0000 |
| Subject: | Re: is there a static constructor? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-312155@lists.php.net to get a copy of this message | ||
class Daz_Config {
private static $instance;
private function __construct(){
$this->load();
}
private function load() {
...
}
public function get($key) {
...
}
public static getInstance(){
if (!self::$instance) self::$instance = new Daz_Config();
return self::$instance;
}
}
Then you can do:
Daz_Config::getInstance()->get('myvalue');