static - PHP - Singleton that returns boolean -


I created a singleton class but I want to work steady, which makes an example to return the bullion value instead of the class thing. This is the way I have setup now, it is not working, so I think I can just return one example. In other words, the function does not return right or wrong; It does not return anything.

  class cache mackin {personal fixed $ _cache; Personal Work __construct () {} Public Fixed Work CreateNew (& amp; $ cacheFile) {if (! Isset (self :: $ _ cache)} {$ object = __CLASS__; Self: $ _ cache = new $ object (); } If (file_exists ($ cachefile)) {readfile ($ cacheFile); Back true; } Other {return false; }}    

change # 1:

  private Fixed $ _cache = NULL;   

Change # 2:

  if (auto :: $ _ cache === tap) {$ object = __CLASS__; Self: $ _ cache = new $ object (); }    

Comments