Tuesday, December 16, 2008

Server Root Path with PHP

Here is a simple way to get the server root path with PHP:

$_SERVER['DOCUMENT_ROOT']

Say you want to check if a file exists, you could do this:

file_exists($_SERVER['DOCUMENT_ROOT']."/yourfolder/yourfile.extension")

Putting this in an IF statement will see if the file exists.  If it does, file_exists will return true, else it will return false.

No comments: