I have a PHP script (index.php) that changes the page shown depending on the query part of the URL (using GET). All the links in the page access different “pages” using ?page=pageName and the index.php script loads HTML from text files accordingly (echoing it to the screen).
So, if a user goes to index.php?page=about, my PHP script loads a file called about.php and echoes it in a view container in the browser.
However, I have a big problem: The content I’m loading has PHP scripts inside it, but those scripts aren’t executed when echoed using the index.php script. That makes it impossible for me to load a page that contains, say, a directory listing pulled from a MySQL database.
So basically, I want to know if there is any way that I can echo a PHP file onto a page but execute the PHP code inside the file as well.
For clarity, I have attached an annotated screenshot that describes what I mean:
EDIT: Here’s the link:

Use if statements to include(‘about.php’) in index.php, and put the echo statements inside about.php. If this doesn’t work, please post code examples.