Tag Archives: File path in PHP

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. Continue reading Get Current file path,Directory Path, Parent Directory Path in PHP