Posted By

MMDeveloper on 02/24/09


Tagged

php include path server setting


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

luman
fabianwizenfeld
umang_nine
vali29
BrianCoyDesign


get absolute server path


 / Published in: PHP
 

URL: http://www.mechanicmatt.com/toDo/

This is useful if you have a settings file for your site and your site has countless numbers of includes that use absolute paths. Instead of hardcoding all the paths and changing them all (if your server environment changes) you can make it dynamic.

FILE is the absolute server path to the script executing it. Running it through the dirname function will trim off the filename, leaving only the absolute server path.

  1. $serverPath = dirname(__FILE__);
  2.  
  3. include($serverPath . "/includes/someFile.php");

Report this snippet  

You need to login to post a comment.