PHP basename( ) Function
PHP functions are a self-centric block of statements that can be executed a number of times as per the developer's requirements.
PHP contains multiple inbuilt functions that can be used at times of need. In these functions, we don't have to give the definition of functions; all we have to do is declare the function and add parameters to use the same.
PHP inbuilt functions:
PHP Basename() function
The basename function is an inbuilt PHP function mainly used to return the base name of a given file on a certain condition when the path of the desired file is given as a parameter inside the base name function. i.e., it gives the trailing name of the path.
PHP basename() functions hold two parameters which are mandatory for the function to execute.
Here in this program, we have declared a variable $path and assigned the file's directory location whose base name we have to use. And in the echo statement, we have used the basename ( ) function with the path as a parameter, which will let the compiler display only the file name.
Here in this program, we have declared a variable $path and assigned the file's directory location whose base name we have to use. And in the echo statement, we have used the basename ( ) function with two parameters, path to assign the path of file and suffix, which will remove the file extension, and the compiler to display only the file name without the. PHP extension.
a ) myfirstPHPfile b ) mySecondPHPfile.php c ) en_US d ) langdata f ) Autoplay g ) software h ) D: i ) . j ) k ) Array ( [dirname] => D:\software\Autoplay\langdatan_US [basename] => mySecondPHPfile.php [extension] => php [filename] => mySecondPHPfile )
Here in this program we have declared a variable $path and assigned multiple values to it displaying all the forms in which the base name function can be utilised.