PHP basename() 函数 basename() 函数可以返回路径的最后一部分名称。 语法 string basename ( string path [, string suffix] )PHPCopy 这个函数接收一个包含文件路径的字符串,并返回文件的基本名称。如果文件名以后缀结尾,也可以将其去掉。 示例 <?php path = "/PhpProject/index.php";file = basename(path); //file is set to "index.php" echo file . "\n";file = basename(path, ".php"); //file is set to "index" echo $file; ?>PHPCopy 输出 index.php indexPHPCopy