title: wrong path using 'require'
body: <p>Since moving my website from local to online , I have a path problem using <strong>require</strong>.</p>
  
  <p>I have pages that call <strong>bootstrap.php</strong> like this: </p>
  
  <pre><code>require 'inc/bootstrap.php';
  </code></pre>
  
  <p>And <strong>boostrap.php</strong> looks like this: </p>
  
  <pre><code>&lt;?php
  spl_autoload_register('app_autoload');
  
  function app_autoload($class){
  require "class/$class.php";
  }
  </code></pre>
  
  <p>This worked well in local.</p>
  
  <p>Now, online, I get the following message:</p>
  
  <pre><code>Warning: require_once(/home/website/www/class/functions.php): failed to open stream: No such file or directory in /home/website/www/inc/bootstrap.php on line 6
  
  Fatal error: require_once(): Failed opening required '/home/website/www/class/functions.php' (include_path='.:/usr/share/php:/usr/share/pear') 
  in /home/website/www/class/functions.php on line 6
  </code></pre>
  
  <p>So I thought, I should put an absolute path in <strong>boostrap.php</strong> like this:</p>
  
  <pre><code>&lt;?php
  spl_autoload_register('app_autoload');
  
  function app_autoload($class){
  $path = $_SERVER['DOCUMENT_ROOT'] . "class/$class.php";
  require_once "$path";
  }
  </code></pre>
  
  <p>But I get the exact same error.
  I dont understand why it is still looking in the /home/website/www/inc/bootstrap.php and not following the absolute path which is /home/website/www/class/functions.php ?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>After testing the different solutions using absolute pathes, I am still getting the error that "No such file or directory in /home/website/www/bootstrap.php: so it is still looking in the file instead of directory. </p>
  
  <p>Could it be because I am using <strong>a double require</strong>? I first require <em>boostrap.php</em> from <em>description.php</em> (which works fine) and then I require <em>class.php</em> from this <em>boostrap.php</em> (which doesent take the absolute path but the path corresponding to the file <em>boostrap.php</em> ?</p>
  
  <p><strong>ANSWER:</strong></p>
  
  <p>Ok it finally works with this configuration:</p>
  
  <p>First file using require:</p>
  
  <pre><code>    require_once(dirname(__FILE__). '/inc/bootstrap.php');
  </code></pre>
  
  <p>and boostrap.php:</p>
  
  <pre><code>    require_once(dirname(__FILE__). "/../class/$class.php");
  </code></pre>