title: Can I instantiate a PHP class inside another class?
body: <p>I was wondering if it is allowed to create an instance of a class inside another class.</p>
  
  <p>Or, do I have to create it outside and then pass it in through the constructor? But then I would have created it without knowing if I would need it.</p>
  
  <p>Example (a database class):</p>
  
  <pre><code>class some{
  
  if(.....){
  include SITE_ROOT . 'applicatie/' . 'db.class.php';
  $db=new db
  </code></pre>