PHP function dirname()

Availability in PHP 4.0

Returns directory name component of path

Parameters

Parameter Data type Default value Note
$path string not A path.
$levels int 1 The number of parent directories to go up. This must be an integer greater than 0.

Return values

string

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 /component removed.

Additional resources

Official dirname documentation

Newsletter

Nejlepsi tipy a triky o PHP do Vaseho e-mailu. Clanky a novinky nejen ze sveta PHP a programovani.