title: PHP 'non-object' error
body: <p>I'm working on a small MVC framework in PHP for an exercise. PHP, however, doesn't seem to like my Controller class. The class contains an instance of a loader that loads views:</p>
  
  <pre><code>abstract class Controller
  {
      public $load;
      function __construct($load) 
      {
          $this-&gt;load = $load;
      }
      abstract public function index();
  }
  </code></pre>
  
  <p>From there, I can override Controller for all my controllers. For instace, my index controller:</p>
  
  <pre><code>class Index extends Controller
  {
      public function index()
      {
          $this-&gt;load-&gt;view("hello_world");
      }
  }
  </code></pre>
  
  <p>But when I create it:</p>
  
  <pre><code>require 'Controller.php';
  require 'Load.php'
  require 'controllers/Index.php';
  $i = new Index(new Load());
  $i-&gt;index();
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>PHP Fatal error:  Call to a member function view() on a non-object in /var/www/controllers/Index.php on line 7
  </code></pre>
  
  <p>Can you guys help me out? I <em>know</em> I set the load in the constructor, and the load class <em>does</em> have a method called view, so why is it giving me this error?
  Also: Load class, just for good measure</p>
  
  <pre><code>class Load
  {
      public function view($filename, $data = null)
      {
          if(is_array($data)) extract($data);
          include ROOT.DS.'views'.DS.$filename.'.php';
      }
  }
  </code></pre>