← All built-ins / dirname()

dirname()

dirname(string $s): string

Parameters

NameTypeDescription
$pathstringfile path

Return value

The directory part of the path.

Example

echo dirname("/var/www/index.hphp"), "
";
echo dirname("script.hphp"), "
";
/var/www
.

See also

basename()pathinfo()realpath()