PHP获取目录中的所有文件名以进行页面切换

Right now I have all my pages under a switch case for when a visitor uses whatever.php?p=pagename

Here is how it is currently

switch($page)
    {
        case 'about':
            include('pages/about.php');
            break;
        case 'contact':
            include('pages/contact.php');
            break;
        case 'edb':
            include('pages/edb.php');
            break;
        case 'eluna':
            include('pages/eluna.php');
            break;
        case 'mercsys':
            include('pages/mercsys.php');
            break;
        case 'pastebin':
            include('pages/pastebin.php');
            break;
        case 'projects':
            include('pages/projects.php');
            break;
        case 'sites':
            include('pages/sites.php');
            break;
        case 'soon':
            include('pages/soon.php');
            break;
        case 'sqlgen':
            include('pages/sqlgen.php');
            break;
        case 'wcms':
            include('pages/wcms.php');
            break;
        case 'add':
            include('pages/add.php');
            break;
        case 'edit':
            include('pages/edit.php');
            break;
        case 'delete':
            include('pages/delete.php');
            break;
        case 'moveAnnouncement':
            include('pages/moveAnnouncement.php');
            break;
        default:
            include('pages/404.php');
    }

My question is, How can I shorten this down to a foreach loop and use the page names for each .php in the pages/ directory without having to add each individual one or any future pages?

upd: like @svrnm adviced, you can do some security checks if you not did it before:

$filename = realpath('pages/' . $page . '.php');
if($filename && file_exists($filename)) {
    include($filename);
}

or/and you can build files whitelist first:

$whitelisted = glob("*.php");
if(in_array($page . '.php', $whitelisted) && file_exists($filename)) {
    include($filename);
}