refactoring - How to get rid of singletons in PHP -


i found out singletons bad. couldn't find answer how recreate current code without singleton.

what have now:

class checker {    private static $inst;    public static function getinst() {     if(!isset(self::$inst))         throw new exception("error 13: check module not started.");     else         return self::$inst;    }     function __construct()   {      if(!isset(self::$inst))         self::$inst = $this;     else {         throw new exception("error 10: checker not ready?");         exit;     }    } } 

and use

checker::getinst()->blablafunction(); 

i need in multiple classes , 1 instance of it.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -