basename()
Following example show how to get the filename of current page
$PHP_SELF = $_SERVER[’PHP_SELF’];
echo basename($PHP_SELF);
basename(string path,string suffix) –> returns the filename.
- First argument is used to get the path
- Second argument is optional, basically used to remove the suffix like .php and ect.
For example
$path = “/work/test/test.php”;
$fileName1 = basename ($path);
$fileName2 = basename ($path,”.php”);
NOw $fileName1 contains test.php and $fileName2 contains test only
