The basename() function returns the filename portion of the path.
basename(path,suffix)
parameter | describe |
---|---|
path | Required. Specifies the path to be checked. |
suffix | Optional. Specifies the file extension. If the file name has a file extension, this extension will not be displayed. |
<?php$path = "/testweb/home.php";//Show filename with file extensionecho basename($path) ."<br/>";//Show filename without file extensionecho basename($path,".php ");?>
The above code will output:
home.phphome