basename()
创建于 2024-12-03 /
34
字体:
[默认]
[大]
[更大]
❮ PHP 文件系统参考手册
$path = "/testweb/home.php";
//Show filename
echo basename($path) ."<br/>";
//Show filename, but cut off file extension for ".php" files
echo basename($path,".php");
?>
home
❮ PHP 文件系统参考手册
实例
从指定路径返回文件名:
<?php$path = "/testweb/home.php";
//Show filename
echo basename($path) ."<br/>";
//Show filename, but cut off file extension for ".php" files
echo basename($path,".php");
?>
上述代码的输出为:
home.phphome
定义和用法
basename() 函数返回路径中的文件名部分。
语法
basename(path, suffix)参数值
参数 | 描述 |
---|---|
path | 必需。规定要检查的路径。 |
suffix | 可选。规定文件扩展名。如果文件有 suffix,则不会输出这个扩展名。 |
技术细节
返回值: | 函数返回路径中的文件名部分。 |
---|---|
PHP 版本: | 4.0+ |
❮ PHP 文件系统参考手册
0 人点赞过