php - Constructor vs static instance -


i new php , had work existing code base. in library there class deals mysql database. however, start instantiate object static getinstance function:

public static function get_instance() {   if(null == self::$instance) {     $c = __class__;     self::$instance = new $c();   }   return self::$instance; } 

i don't see advantage of static function in comparison usual constructor. how have deal login credentials? have make them static, too?


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -