← All built-ins / basename()

basename()

basename(...$args): string

Parameters

NameTypeDescription
$pathstringfile path
$suffixstringstripped from the end when presentoptional

Return value

The file name part of the path.

Example

echo basename("/var/www/index.hphp"), "
";
echo basename("page.html", ".html"), "
";
index.hphp
page

See also

dirname()pathinfo()