When you want to isolate the base filename from a path string, this is the way to do it:
$path = "/home/project/folder/mypage.php"; $file = basename($path); // $file is "mypage.php" $file = basename($path, ".php"); // $file is "mypage"
See dirname() and pathinfo() for related information.