English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Filesystem Reference Manual
The basename() function can return the file name part in the path.
string basename ( string path [, string suffix] )
It returns a string containing the file path and this function returns the base name of the file. If the file name ends with a suffix, it can also be truncated.
<?php $path = ""/PhpProject/index.php"; $file = basename($path); // $file is set to "index.php" echo $file . "\n"; $file = basename($path, ".php"); // $file is set to "index" echo $file; ?>
Output Result
index.php index