Let's take a look at the components of the component path.
Basename Function instance tutorial
Basename
(PHP 4 and PHP 5)
Basename-components of the returned file path
Description
String basename (string $ path [, string $ suffix])
Given that a string contains a path file, this function returns the base file name.
Parameters
Path
A path.
In Windows, the two slash (/) and backslash () are used as directory separators. In other environments, it is a forward slash (/).
Suffix
If the file name ends with the suffix is also cut off.
Return value
Return base name to specify the path.
Modify
Version description
Add Extension Parameters for 4.1.0
Instance
Example #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"
?>