PHP dirname() Function

Return the path of the parent directory

Definition and Usage

The dirname() function returns the path of the parent directory.

Syntax

dirname(path, levels)

Parameter Values

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

Technical Details

Return Value: The path of the parent directory on success
PHP Version: 4.0+
Binary Safe: Yes, in PHP 5.0
PHP Changelog: PHP 7.0 - Added the levels parameter

❮ PHP Filesystem Reference