All pastes #103062 Raw Edit

Unnamed

public text v1 · immutable
#103062 ·published 2006-07-28 02:36 UTC
rendered paste body
class myClass {
    private static $instance;
    private function __construct() { }
    private function __desconstruct() { }
    public function __clone() { trigger_error("Can\'t clone singleton.", E_USER_ERROR); }
    public function Instance() {
           if (!isset(self::$instance))
           {
               self::$instance = new self;
           }
           return self::$instance;
    }
}

$obj = myClass::Instance(); //<<-- triggers __clone() for some reason.