Home > Web Front-end > JS Tutorial > body text

php basename function

黄舟
Release: 2016-12-15 11:09:06
Original
1464 people have browsed it

Let’s take a look at the tutorial below to provide an example of the basename function that is a component of the file path

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 archive name.

Parameters

Path
A path.

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

Suffix
If the file name ends with a suffix, it will also be cut off.


Return Value
Returns the path specified by the base name.

Modify

Version Notes
The suffix parameter of 4.1.0 is added


Example

For 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"
? >

The above is the content of the php basename function. For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!