php The dirname() function returns the directory part of the path. Its syntax is [dirname(path)]. The parameter path is required and refers to the path to be checked.
php dirname function usage:
php dirname() function syntax
Function: Returns the directory portion of the path.
Syntax:
dirname(path)
Parameters:
path Required. Specifies the path to be checked.
Explanation: The
path parameter is a string containing the full path to a file. This function returns the directory name after removing the file name.
php dirname() function example
<?php $file = "/phpstudy/WWW/index.php"; echo dirname($file); ?>
Output:
/phpstudy/WWW
This article is an introduction to the PHP dirname function. I hope it will be helpful to friends who need it. Helps!
The above is the detailed content of How to use php dirname function. For more information, please follow other related articles on the PHP Chinese website!