string basename ( string $path [, string $suffix] );
如果给定一个包含文件路径的字符串,此函数将返回文件的基本名称。
path - 文件路径。
suffix - 如果文件名后缀。
链接:https://www.learnfk.comhttps://www.learnfk.com/php/php-function-basename.html
来源:LearnFk无涯教程网
它返回给定路径的基本名称。
<?php $path="/home/httpd/html/index.php"; $file=basename($path); echo "File name is $file\n"; $file=basename($path, ".php"); echo "File name is $file\n"; ?>
这将产生以下输出-
File name is index.php File name is index
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)