Will the same singleton instance be available after php script command line call?
<p>I have script with defined class (for instance, Singleton.php). This class implements classic singleton pattern as in PHP manual:</p>

<pre><code> class Singleton   {
    private static $instance;

    public static function getInstance() 
    {
       if (!isset(self::$instance)) {
           $c = __CLASS__;
           self::$instance = new $c;
       }

       return self::$instance;
    }
    public function run() {
        // bunch of "thread safe" operations
    }  }

$inst = Singleton::getInstance(); 
$inst-&gt;run();
</code></pre>

<p>Question. If I call this script twice from command line ('<code>php Singleton.php</code>'), will run() method be really "thread safe"? It seems that it will not. I used to imitate single-process run via text file where some flag is stored, but it seems that there might be other cases. Your thoughts?</p>
