What Gumbo said for checking if the index is set in the array.
Also for parsing an array index in a string you should use brackets around the array, and you should escape the index with single quotes if it is a string.
$page = realpath("includes/{$_GET['p']}.php");
But for including files suggested by the user, the safest way is to look up the files in an array, and only include them if they exists there.