title: How to execute php code through the query string filename without including?
body: <p>I'm trying to execute the php code dynamically using the filename as the query string like <code>index.php?q=script1</code>. What I've done so far, works but only when I use include for the passed file in the main index.</p>
  
  <pre><code>&lt;?php 
      include("class.php"); 
  
      if (!empty($_GET['q'])) {
          $sp = $_GET['q'];
          $sp = basename($sp);
          $location = 'src/scripts/' . $sp . '.php';
  
          if (file_exists($location)) {
              file_get_contents($location); // Tried, does not work
              shell_exec('php -f /' . $location); // This does not work either
              include($location); // This works
          }
      }
  ?&gt;
  </code></pre>
  
  <p>I'm looking for a way to execute em without actually including the file in the main index. Is is possible?</p>