Base name;Basic name
php basename() function syntax
Function: Return the file name part of the path.
Syntax: basename(path,suffix)
Parameters:
Parameter | Description |
path | Required. Specifies the path to be checked. |
suffix | Optional. Specifies the file extension. If the file has suffix, this extension will not be output. |
#Description: Returns the file name part of the path.
php basename() function example
<?php $file = "/phpstudy/WWW/index.php"; echo basename($file);//带有文件扩展名 echo "<br>"; echo basename($file,'.php'); //去除文件扩展名 ?>
Run instance»
Click the "Run instance" button to view the online instance
Output:
index.php index