php dirname() function
Translation results:
Directory name; return the directory part of the path; directory name
php dirname() functionsyntax
Function: Return the directory part of the path.
Syntax: dirname(path)
Parameters:
Parameter | Description |
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() functionexample
<?php $file = "/phpstudy/WWW/index.php"; echo dirname($file); ?>
Run instance»
Click the "Run instance" button to view the online instance
Output:
/phpstudy/WWW