The dirname() function returns the directory name from a path.
string dirname ( string $path [, int $levels = 1 ] )
Given 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.
The output of the code above will be:
Parameter | Description |
---|---|
path | On Windows, both slash (/) and backslash (\) are used as directory separator character. In other environments, it is the forward slash (/). |
levels | The number of parent directories to go up.This must be an integer greater than 0. |