title: one class instance
body: <p>is there a way to prevent the instance of the same class in a PHP script?</p>
  
  <pre><code>$user = new User();
  
  
  $user2 = new User();  // I want to catch another instance of the user class and throw an exception
  </code></pre>
  
  <p>I have tried creating a static variable and manipulating it with a static function:</p>
  
  <pre><code>User::instance()
  </code></pre>
  
  <p>but that doesn't stop me from doing:</p>
  
  <pre><code>$user = new User();
  </code></pre>