PHP 5 → 4 converter




(download as file)
<?php


$GLOBALS['Example::$instance'] = NULL; /* class private static property */
class Example
{
   // Hold an instance of the class
   // The singleton method
   function singleton() /* static */
   {
       if (!isset($GLOBALS['Example::$instance'])) {
           $c = __CLASS__;
           $GLOBALS['Example::$instance']= new $c;
       }

       return $GLOBALS['Example::$instance'];
   }

}

// This will always retrieve a single instance of the class
$test = Example::singleton();
$test->bark();

?>