Capturing the filename from a path in PHP

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.

About Rob