Last Good Quote: Son's are the seasoning on our lives. - Someone on Facebook

Monday, July 16

PHP Code: Get Root Folder

The following snippet will return the root path of a file. This is usfull when running an include within an included file. Sometimes you don't know what directory it will be excuted from

ULR: http://snippets.dzone.com/posts/show/4210

function
getCurrentDirectory() {
 $path = dirname($_SERVER['PHP_SELF']);
$position = strrpos($path,'/') + 1;
return substr($path,$position);
}

0 comments:

Post a Comment

Followers