如果URL包含'foo',则查找并包含匹配的PHP include

I've written some code that includes 'home.php' if the URL contains 'index.php':

<?php if($_GET['page'] != "index.php") {
include('_includes/home.php');  } ?>  

This works fine for a specific page (in this instance the home page), but I want to extend this logic for any page on my site. For instance if the URL contained 'foo2.php' I'd want the the PHP to search for and include '_includes/foo2.php'.

I'm new to php so any help would be appreciated.

if the URL was:

http://example.com/?page=foo2

if (empty($_GET['page'])){
  include ("_includes/index.php");
  exit;
}
$Page_Search = glob("_includes/*.php");

if (in_array($_GET['page'],$Page_Search)){
 include ("_includes/$page.'.php');
 exit;
}

This might be of use.

How about:

if(isset($_GET['page'])) include "_includes/{$_GET['page']}.php";