PHP Tutorial - PHP dirname() Function






Definition

The dirname() function returns the directory name from a path.

Syntax

PHP dirname() Function has the following syntax.

dirname(path)

Parameter

ParameterIs RequiredDescription
pathRequired.Path to check

Return

PHP dirname() Function returns the directory name from a path.

Example


<?php
echo dirname("c:/test/home.php") . "\n";
echo dirname("/test/home.php");
?>

The code above generates the following result.