One functions I wish I had known about when i start learned PHP is the realpath() function. Pretty much what it does is take symbolic link (such as ‘../’ or ‘/’) and returns a canonicalized absolute link (like ‘/home/public_html/folder’). Here is an example of it in action:
<?php
echo realpath('../');
// Would return: /home/mike/www/blogposts
?>








The most common use of realpaths would be as a base path. If you set the path as a constant BASE for example and add a ‘/’. Putting this constant inside every include file would make your system indepent from its surroundings. So moving the directory shouldn’t coss too much problems when you use this.
An alternative is also the dirname(__FILE__) function. Which returns the path to the file that is currently executing.