Definition:
The basename() function in PHP is an inbuilt function which is used to return the base name of a file if the path of the file is provided as a parameter to the basename() function.
basename(path, suffix)
Parameter | Description |
---|---|
path | Required. Specifies a file path |
suffix | Optional. A file extension. If the filename has this file extension, the file extension will be cut off |
Errors And Exception:
Given below example Return filename from the specified path:
Output : index.php
index