title: Path issue with autoload function to get files for use in Ajax
body: <p>So my project uses an MVC framework and I have a page with an Ajax script I run to get content from the server.  When the PHP script is called in the Ajax script, I want to access the classes already in my library for use in the PHP script.  To do this, I use what I call an ajaxBootstrap to call the appropriate function that then instantiates the objects needed for that specific Ajax script.</p>
  
  <p>To load those classes from my library I have an autoload function in my ajaxBootstrap so I don't need to use a bunch of require and include statements.  My problem is those files aren't being loaded due to a path issue with the autoload function.  When I use a require statement with the same path, the classes load with no problems, its only when I try to load them using the autoload function that I get an 500 internal server error.</p>
  
  <p>Here is my ajaxBootstrap file:</p>
  
  <pre><code>// This file routes Ajax requests made in JS files and instantiates a specific object to carry out the actions needed for that particular Ajax operation 
  
  // Autoload any classes that are required
  function autoLoad($classToLoad)
  {
      if(file_exists('../library/' . $classToLoad . 'class.php')) // File in the library folder
      {
          require('../library/' . $classToLoad . '.class.php');
     }
      else if(file_exists('../../app/models/' . $classToLoad . 'class.php')) // File in the models folder
      {
          require('../../app/models/' . $classToLoad . '.class.php');
      }
  }
  
  spl_autoload_register('autoLoad');
  
  // Determine which function to call based on the url that's listed in the Ajax request
  switch($_GET['action'])
  {
      case 'pageOne':
          pageOne();
          break;
      case 'pageTwo':
          pageTwo();
          break;
  }
  
  function pageOne()
  {
      $test = new Test();
      $test-&gt;funcThatReturnStuff();
  }
  
  function pageTwo()
  {
      $test2 = new Test2();
      $test2-&gt;funcThatReturnStuff();
  }
  </code></pre>
  
  <p>Like I mentioned eariler, if I use a require statement such as:</p>
  
  <pre><code>require('../library/Test.class.php');
  $test = new Test();
  $test-&gt;funcThatReturnStuff();
  </code></pre>
  
  <p>The class loads and works just fine.  But using the same path in the autoloader function throws an error.  The really odd thing is if I put an else if statement in the autoloader that loads a class from the folder where my ajaxBootstrap is it also works fine too...</p>
  
  <p>I know I could just use the require statements and be done with the problem but I want to be able to scale the project and not need to use loads of require statements in the future.  BTW, I use '../' to get from where my ajaxBootstrap file is to my other folders.</p>
  
  <p>Also, to add to my previous post, I've tried replacing the <code>../</code> with absolute paths using <code>define('ROOT', dirname(__FILE__) . '/')</code> and also <code>define('ROOT', $_SERVER['DOCUMENT_ROOT'] . '/path/to/folder/')</code> neither of which worked and still gave me the internal server error in Firebug.  In addition, I haven't received any errors in my error log either.</p>