dirname in PHP December 13, 2021 by Codingtube team Syntax of dirname in PHP string dirname(string path) Returns the directory component of path. This includes everything up to the filename portion (see basename) and doesn’t include the trailing path separator. Example of dirname in PHP