title: /.. Not working in PHP
body: <p>For requiring files in my PHP scripts I am using the following code :</p>
  
  <pre><code>require(dirname(__FILE__)."/../config.php");
  </code></pre>
  
  <p>with the config.php file being located a level higher than the file requiring it. However this appears to not work and the file cannot be located, with the following error :</p>
  
  <pre><code>failed to open stream: No such file or directory in /home3/**myusername**/public_html/PHP/access/login.php on line 3
  </code></pre>
  
  <p>I'm not sure what the error is as I have looked online and this appears to be the way others have done it. I believe however that the /.. is not causing it to go up a level.</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>I changed the code to</p>
  
  <pre><code>require_once($_SERVER['DOCUMENT_ROOT'] . "/PHP/config.php");
  </code></pre>
  
  <p>and still receive the same error.</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>The reason I am using an absolute path is because I have been led to believe this will work no matter where I call the file from, i.e if a file in a different directory includes this file (for this particular file it wont be the case but it will be in other files where I will use this) it will still include the config.php file correctly and not relative to the path of the file that included login.php.</p>
  
  <p><strong>EDIT 3</strong></p>
  
  <p>if I vardump the require path it prints the following :</p>
  
  <pre><code>string(52) "/home3/*myusername*/public_html/PHP/access/../config.php" 
  </code></pre>
  
  <p>so obviously not going to the right location.</p>
  
  <p><strong>EDIT 4</strong></p>
  
  <p>Absolute path of file being required</p>
  
  <pre><code>/home3/*myusername*/public_html/PHP/config.php
  </code></pre>
  
  <p>Absolute path of file requiring it</p>
  
  <pre><code>/home3/*myusername*/public_html/PHP/access/login.php
  </code></pre>