Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
PHP Singleton Class
SUBMITTED BY:
Guest
DATE:
Nov. 11, 2013, 11:53 a.m.
FORMAT:
PHP
SIZE:
535 Bytes
Raw
Download
Tweet
HITS:
890
Go to comments
Report
class singleton {
private static $instance = null;
private function singleton() { }
public static function &getInstance() {
if(is_null(self::$instance)) self::$instance = new self();
return self::$instance;
}
public function __destruct() { }
public function __clone() {
trigger_error('Cloning instances of this class is forbidden.', E_USER_ERROR);
}
public function __wakeup() {
trigger_error('Unserializing instances of this class is forbidden.', E_USER_ERROR);
}
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus