title: Have only one instance of a class
body: <p>I was wondering how I can get one instance of the following db connection.</p>
  
  <p>For example, lets say this is my class in the file Database.php</p>
  
  <pre><code>public class Database {
      public function __construct() {
        try {
              // PDO Here
              print("Connected!");
          } catch (PDOException $e) {
              die($e-&gt;getMessage());
          }
      }
  }
  </code></pre>
  
  <p>index.php</p>
  
  <pre><code>Database();
  Database();
  </code></pre>
  
  <p>Result</p>
  
  <p><code>Connected!Connected!</code></p>
  
  <p>I want to instantiate the class only once even if I call it twice.</p>