Home  >  Article  >  Backend Development  >  php basename function_PHP tutorial

php basename function_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:00:38852browse

Let's take a look at the tutorial that provides an example of the basename function, which is a component of the file path. ​

Let’s take a look at the components that provide a file pathbasenamefunction example tutorial

basename
(PHP 4, PHP 5)

basename - Returns the components of the file path

Description
String basename (String$path[,String$suffix])
Given a string containing the path to the file, this function will return the base file name.

Parameters

Path
a path.

In Windows, both slash ( / ) and backslash ( ) serve as directory separators. In other environments, it is a forward slash ( / ).

Suffix
The file name will also be cut off if it ends with a suffix.


Return value
Returns the path specified by the base name.

Modify

Release Notes
The suffix parameters of 4.1.0 are increased


Example

Example #1 basename() example

$path = "/home/httpd/html/index.php";
$file = basename($path); // $file is set to "index.php"
$file = basename($path, ".php"); // $file is set to "index"
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445492.htmlTechArticleLet’s take a look at the basename function example tutorial that provides a component of the file path. Let’s take a look at the basename function example tutorial that provides a file path. Components of the path basename function example tutorial basename (PHP...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn