请输入您要查询的百科知识:

 

词条 basename
释义

(PHP 3, PHP 4, PHP 5)

basename -- 返回路径中的文件名部分

说明

string basename ( string path [, string suffix] )

给出一个包含有指向一个文件的全路径的字符串,本函数返回基本的文件名。如果文件名是以 suffix 结束的,那这一部分也会被去掉。

在 Windows 中,斜线(/)和反斜线(\\)都可以用作目录分隔符。在其它环境下是斜线(/)。

例子 1. basename() 例子

<?php

$path = "/home/httpd/html/index.php";

$file = basename($path); // $file is set to "index.php"

$file = basename($path,".php"); // $file is set to "index"

//同样也可以这样

$path_other = $_SERVER['DOCUMENT_ROOT'];

$test_file = $path_other.basename($_FILES['file_ep']['name']);//file_ep是上传文件的name 值

?>

在linux下basename的作用是:显示文件或者目录的基本名称

用法:basename 名称[后缀]

或 basename 选项

随便看

 

百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2025/2/24 23:34:30