Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

PHP: how to "clone from" another object of same class

class Singleton {
    protected static $instance; 
    
    protected function __construct() { 
    }
    
    public static function instance() {
        if (self::$instance === null) {
            self::$instance = new self();
        }
        return self::$instance;
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #object #class
ADD COMMENT
Topic
Name
3+7 =