Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

PHP: Get The Name Of The Directory Which Contains The Current Script

DZone 's Guide to

PHP: Get The Name Of The Directory Which Contains The Current Script

· Web Dev Zone ·
Free Resource

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



Topics:
php ,web dev

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}