PHP basename() 函数

PHP basename() 函数

basename() 函数可以返回路径的最后一部分名称。

语法

string basename ( string path [, string suffix] )
PHP

这个函数接收一个包含文件路径的字符串,并返回文件的基本名称。如果文件名以后缀结尾,也可以将其去掉。

示例

<?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;

?>
PHP

输出

index.php
index
PHP

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

登录

注册