Current Location: Home> Function Categories> basename

basename

Returns the file name part in the path
Name:basename
Category:File system
Programming Language:php
One-line Description:Returns the file name part in the path.

Definition and usage

basename() function returns the file name part in the path.

Example

 <?php
$path = "/testweb/home.php" ;

//Show filename with file extension
echo basename ( $path ) ;

//Show file names without file extension
echo basename ( $path , ".php" ) ;
?>

Output:

 home.php
home

grammar

 basename ( path , suffix )
parameter describe
path Required. Specify the path to be checked.
suffix Optional. Specify file extensions. If the file has suffix, this extension will not be output.
Similar Functions