Home  >  Article  >  Backend Development  >  php dirname function returns the directory name_PHP tutorial

php dirname function returns the directory name_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:00:56931browse

php dirname function returns the directory name ​ dirname
(PHP 4, PHP 5)

dirname - Returns the component path of the directory name

Description
String dirname (String $path)
Given a string containing the path to a file, this function will return the name of the directory.

Parameters

Path
a path.

In Windows, both slash ( / ) and backslash ( ) serve as directory separators. In other environments, it is a forward slash ( / ).


Return value
The directory name returned. If there is no slash in the path, a dot ('.') is returned, showing the current directory. Otherwise, the string path is returned with any trailing/components removed.

Modify

Release Notes
5.0.0 dirname ( ) is now binary safe
4.0.3 dirname() is fixed for POSIX compliance.


Example

Example #1 dirname()

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445483.htmlTechArticlephp dirname function returns the directory name dirname (PHP 4, PHP 5) dirname - returns the components of the directory name Path description string dirname (String $path) Given a word...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn