Hi
I need a command that returns the directory name that my file is in
for example if my file is www/javad/codes/getdir.php , then I want to place a code in getdir.php that returns "codes" (and if possible "javad")
Thanks for your help
detecting directory
Moderator: General Moderators
Re: detecting directory
__FILE__ is a magic constant that gives you the full path to the file it's used it. With some combination of dirname and basename...
Code: Select all
// __FILE__ is /path/to/file.php
echo basename(__FILE__); // file.php
echo basename(dirname(__FILE__)); // to
echo basename(dirname(dirname(__FILE__))); // path
echo basename(dirname(dirname(dirname(__FILE__)))); // .