Including file based on user input: Efficiency and Security
Assuming nobody but you can place files in the directory, this will be safe because you are checking the input page against a pre-defined list of page files. Additionally, this code makes the white list dynamic and throws an exception if the page is not found.

As @tim said in the comment, he found this code to be about 5 times slower then yours. So that's good to keep in mind if you ever decide to use this.

Every .php page you put in the pages/ directory will automatically be callable.

if (isset($_GET['p'])) {
    $page  = $_GET['p'] . '.php';
    $pages = array_map('basename', glob('pages/*.php'));

    if (in_array($page, $pages)) {
        include('pages/' . $page);
    } else {
        throw new Exception('Page "' . $page . '" does not exist.');
    }
} else {
    echo 'Hi';
}