Get Current file path,Directory Path, Parent Directory Path in PHP

$module_name = basename(dirname(__FILE__));
__FILE__ returns the filename of the script that is currently being run.
dirname returns the directory of a given filename.
basename() returms the filename component of path. To put it better: it strips any “parent” directories off a given string.

The constant __FILE__ in PHP always returns the absolute path to the script file that’s currently active – the PHP file in which the code line is being run right now. Function dirname() returns the directory part of the given path.

Suppose you run /home/httpd/html/index.php, which contains the following PHP Code line-
echo basename(dirname(__FILE__));

Now __FILE__ gives “/home/httpd/html/index.php”,
dirname(__FILE__) gives “/home/httpd/html” and
basename(dirname(__FILE__)) gives “html”.

So basename() stripped the “parent” directory “/home/httpd/” off the string “/home/httpd/html”. Don’t be confused of the fact that /home/httpd/html is a directory, but basename is supposed to operate on “filenames”. Internally, a directory is just another file, so a directory name is treated like a filename.
Some Good Reference :