从指定路径返回文件名:
<?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");
?>
上面代码的输出将是:
home.html
home
basename() 函数从路径返回文件名。
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 |
返回值: | 指定路径的文件名 |
---|---|
PHP 版本: | 4.0+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!