Find Server Absolute Path with PHP
Shifting websites between servers and installing applications such as Wordpress is a common task for web designers, and sooner or later you'll need to set or reconfigure the absolute path for the server. PHP offers a nifty function to display this for you with a small line of code.
Open your chosen editor (dreamweaver / notepad) and paste into it the following code:
< ?php
$p = getcwd();
echo $p;
? >
(remove the character space after the opening "<" and before the closing ">")
Save the file as as a PHP document (for example "abpath.php") and upload it to your server somewhere you can access it through your browser. For example www.yourwebsiteaddress.com/abspath.php
Hey presto, you'll be presented with the absolute path to the directory you uploaded the php file to.
Note: You'll need to have a PHP enabled server for this to work.








2 Comments
Thanks the good information here. Thanks for sharing. <a href="http://www.premierpixels.com">Las Vegas Web Design</a>
There are many methods in PHP to find server path. Another less used but quite useful method is realpath ( string $path ). It provides the canonicalized absolute pathname which is useful at times.