函式:basename()


basename

传回不含路径的档案字串。

语法: string basename(string path);

传回值: 字串

函式种类: 档案存取

内容说明

将含路径及档案字串中的路径拿掉,传回只含档名的字串。在 Windows 系列的作业系统中,路径可以是斜线 (/) 或反斜线 (\);在 UNIX 系列的作业系统,路径为斜线 (/)。

使用范例

下例中的 $file 变数值为 "index.php"

<?php
$path 
"/home/httpd/html/index.php";
$file basename($path);
?>

参考

dirname()  


[ 上一页 下一页 ]