Definition :
The PHP dirname() function returns a string containing the path of a file or directory, this function will return the parent directory's path that is levels up from the current directory.
dirname(path, levels)
Parameter | Description |
---|---|
path | Required. Specifies a path to check |
levels | Optional. An integer that specifies the number of parent directories to go up. Default is 1 |
The example below shows the usage of dirname() function.
Output :
/usr/example/fig
/usr/example
/usr
.
/usr/example