title: private function __construct() not working when class called on another page
body: <p>im using the following type of class...</p>
  
  <pre><code>class datas{
  
  
      protected $req ;
      protected $db ;
  
  
      private function __construct()
      {
          $this-&gt;db = new Database('localhost', 'user', 'pass', 'db');
          $this-&gt;db-&gt;connect(); 
      }
  
      public function prnt()
      {
         echo "afafa6e5f1ga56d18a1ge";
      }
  }
  </code></pre>
  
  <p>when i try and access the class like</p>
  
  <pre><code>$y = new datas();
  $y-&gt;prnt();
  </code></pre>
  
  <blockquote>
    <p>Call to protected data::__construct() from invalid context</p>
  </blockquote>
  
  <p>when i turn it to public, it works. is there any way to make the constructor private and still have the method of call like i have. and i was thinking which one is more secure .</p>
  
  <p>any insight is appreciated guys.</p>