Return filename from the specified path:
<?php
$path = "/testweb/home.html";
//Show filename
echo basename($path) ."<br/>";
//Show filename, but cut off file extension for ".html" files
echo basename($path,".html");
?>
The output of the code above will be:
home.html
home
The basename() function returns the filename from a path.
basename(
path,
suffix)
Parameter | Description |
---|---|
path | Required. Specifies a file path |
suffix | Optional. A file extension. If the filename has this file extension, the file extension will be cut off |
Return Value: | The filename of the specified path |
---|---|
PHP Version: | 4.0+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!