<?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://https://convert.idontcarewhatyouthink.net/program/php/dirname.php"; echo dirname($file); //http://https://convert.idontcarewhatyouthink.net/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_"); //. ?>