<?php
 
/** 
 
 * Singleton class
 
 */
 
 
class Singleton
 
{
 
    /**
 
     * The instance of this class
 
     * @var object
 
     */
 
    private static $instance = null;
 
 
    /**
 
     * Returns only one instance of this class
 
     * @return object
 
     */
 
    public static function GetInstance()
 
    {
 
        if (!self::$instance instanceof self)
 
            self::$instance = new self();
 
        return self::$instance;
 
    }
 
 
    /**
 
     * Private constructor
 
     */
 
    private function  __construct()
 
    {
 
 
    }
 
 
    /**
 
     * No serialization allowed
 
     */
 
    public function __sleep()
 
    {
 
        trigger_error("No serialization allowed!", E_USER_ERROR);
 
    }
 
 
    /**
 
     * No cloning allowed
 
     */
 
    public function __clone()
 
    {
 
        trigger_error("No cloning allowed!", E_USER_ERROR);
 
    }
 
}
 
 
 |