Php - How to return filename component, Find extension of a file name
How to return filename component
Return filename component of path
The function basename() will return the base name of the file.
$path = "/home/malu/html/index.php"; $file = basename($path); // $file is set to "index.php" echo "$file"; ?>
The above code will display the base name with the extension.
Result :
index.php
$path = "/home/malu/html/index.php"; $file = basename($path, ".php"); // $file is set to "index" echo "$file"; ?>
The above code will display only the base name without extension.
Result :
index
The topic on Php - How to return filename component is posted by - Malu
Hope you have enjoyed, Php - How to return filename componentThanks for your time