title: PHP Dynamic page include
body: <p>I have an simple PHP script that includes a file, when it's requested via URL.</p>
  
  <p>for an example: <a href="http://example.com/index.php?page=about" rel="nofollow">http://example.com/index.php?page=about</a>
  So this includes the page about.inc</p>
  
  <p>This is working, but i have another problem. When someone visits the homepage so just:
  <a href="http://example.com/" rel="nofollow">http://example.com/</a> . It will show me this </p>
  
  <pre><code>Undefined index: beta in /home/admin/domains/mydomainname.nl/public_html/index.php on line 3
  </code></pre>
  
  <p>That is:</p>
  
  <pre><code>$page = $_GET['page'];
  </code></pre>
  
  <p>I know I can disable the error notice in PHP, but this is not a solution but a workaround.</p>
  
  <pre><code>$path = 'app/inc/pages/dynamic/';
  $page = $_GET['page'];
  $php  = '.inc';
  $both = $path . $page . $php;
  $pages = array('index', 'home', 'about', 'contact');
  if (!empty($page)) {
  
      if(in_array($page,$pages)) {
          //$page .= '.php';
          include($both);
      }
      else {
      include('app/inc/pages/dynamic/404.inc');
      }
  }
  else {
      include('app/inc/pages/dynamic/home.inc');
  }
  }
  </code></pre>
  
  <p>It does include the homepage via </p>
  
  <pre><code>else {
      include('app/inc/pages/dynamic/home.inc');
  }
  </code></pre>
  
  <p>My question is how to solve this?</p>