I have the following script to do dynamic includes:
<?php
$_GET["page"] = (isset($_GET["page"])) ? $_GET["page"] : "home";
$page = $_GET['page'];
$pages = array('home', 'solutions', 'projects', 'about', 'contact');
if (!empty($page)) {
if(in_array($page,$pages)) {
$page .= '.php';
include($page);
}
else {
echo 'Page not found. Return to
<a href="index.php">index</a>';
}
}
else {
include("home.php");
}
?>
What should I add to this script to be able to also include DYNAMICALLY files from different folders (e.g. I have an index.php page that is in the www/mysite_folder and I want to dynamically include into the index.php the file Adresses.php that is in www/mysite_folder/faq_folder)? Note that by dynamic I don’t mean the regular include (include();) but <a href="index.php?category=faq_folder&page=adresses">Adresses</a>.
I see no reason for splitting executable files between directories.
So, if you can keep all the files in one, here is the code
which is secure and automated.