The dirname() function returns the directory name from a path.
PHP dirname() Function has the following syntax.
dirname(path)
Parameter | Is Required | Description |
---|---|---|
path | Required. | Path to check |
PHP dirname() Function returns the directory name from a path.
<?php
echo dirname("c:/test/home.php") . "\n";
echo dirname("/test/home.php");
?>
The code above generates the following result.