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.
- $serverPath = dirname(__FILE__);
- include($serverPath . "/includes/someFile.php");
You need to login to post a comment.