<?PHP $file="C:\Windows\win.ini"; echo dirname($file); //C:\Windows $file="C:\Windows\win.ini"; echo dirname($file, 2); //C: ?>
It also supports URL file name.
<?PHP $file="http://www.endmemo.com/program/php/dirname.php"; echo dirname($file); //http://www.endmemo.com/program/php ?>
Following code will determine the file path of current file. Because there is no
slash in the path, so a dot (
<?PHP echo dirname("_FILE_"); //. ?>