Home > PHP > Function > Filesystem > dirname()

dirname()

dirname - Returns directory name component of path

Syntax

string dirname (string $path)

Arguments

  • path - A path. On Windows, both slash ( /) and backslash ( \) are used as directory separator character. In other environments, it is the forward slash ( /).

Description

Given a string containing a path to a file, this function will return the name of the directory.

Version

PHP 4, 5

Return value

Returns the name of the directory. If there are no slashes in path, a dot ('.') is returned, indicating the current directory. Otherwise, the returned string is path with any trailing /componentremoved.