Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- abstract class singleton {
- protected static $instance;
- final protected function __construct() {
- $this->construct();
- }
- abstract protected function construct();
- abstract protected function construct($_str);
- final public static function getInstance() {
- if (!isset(static::$instance)) {
- $className = get_called_class();
- $new_instance = new $className();
- if (!isset(static::$instance)) {
- static::$instance = $new_instance;
- }
- }
- return static::$instance;
- }
- final public function __clone() {
- trigger_error("Unable to clone singleton class __CLASS__", E_USER_ERROR);
- }
- final public function __wakeup() {
- trigger_error("Unable to unserialize singleton class __CLASS__", E_USER_ERROR);
- }
- }
- ---------------------------- call function
- <?php
- require_once "util/singleton.class.php";
- class users extends singleton
- {
- protected static $instance;
- private $apple_id = array();
- protected function construct($_str)
- {
- //echo "users run!!!";
- $this->setUser($_str);
- }
- function getUser()
- {
- return $this->apple_id;
- }
- function setUser($_str)
- {
- //$result = mysql_query($_str);
- //$this->apple_id = mysql_fetch_assoc($result);
- echo $_str;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement