There is a library where is the place to be the class, which within the same process allowed the existence of only one instance, i.e. is a Singleton. The trouble is that the initialization of this instance has several dynamic parameters that need somehow to pass.
The solution should work on PHP > 5.2. The only thought that came to mind:
public static function init($params) { if(self::$instance) { throw new Exception(__CLASS__ . 'already initialized'); } $class = __CLASS__; self::$instance = new $class($params); } public static function getInstance() { if(!self::$instance) { throw new Exception(__CLASS__ . 'is not initialized'); } return self::$instance; }
But it seems by far the most successful. Does anyone have any more ideas, adelitas?
Thank you!