自动化PHP包括[关闭]

i am looking for a way to automatize my php script, it should search for php files in a folder called SUBPAGES and include the php files with the Help of a Dropdown like my example but without recoding it everytime i add a new file.

It should find the files stored in the SUBPAGES folder by itself and include the selected file automatized.

Can any one please help me in solving it.

<html>

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">

<div align="center">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td align="center">
<table border="0" cellspacing="0" cellpadding="0" width="" height="">
<tr>
<td width="300" height="50" bgcolor="#F2F2F2">

<p align="center">

<form name="form">
<p align="center">
<select name="link" SIZE="1" onChange="window.location.href = document.form.link.options[document.form.link.selectedIndex].value;">
<option value="#" style="display:none">Choose</option>
<option value="index.php?id=page1"> Seite1 </option>
<option value="index.php?id=page2"> Seite2 </option>
</select></p>
</form>

</td>
</tr>
<tr>
<td height="20" bgcolor="#999999">&nbsp;</td>
</tr>
<tr>
<td height="350">

<?php
error_reporting(0);
switch($_GET['id']) {
default:
include('Subpages/page1.php');
break; case "page2":
include('Subpages/page2.php');
}
?>

</td>
</tr>
</table>
</td>
</tr>
</table>
</div>

</body>

</html>

Simple way. firstly check the type of security, after include

$page = 'Subpages/page'.settype($_GET['id'],'integer').'.php' ;
$defaultpage = 'Subpages/page1.php' ;
if (file_exists($page)) {
        include($page);
}else{
 include($defaultpage);
}

It's more easy with jquery and the load function. You only need to read the value of the selected option and load the file that you need

<div align="center">
    <table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%">
        <tr>
            <td align="center">
                <table border="0" cellspacing="0" cellpadding="0" width="" height="">
                    <tr>
                        <td width="300" height="50" bgcolor="#F2F2F2">

                            <p align="center">

                            <form name="form">
                                <p align="center">
                                    <select name="link" SIZE="1">
                                    <option value="#" style="display:none">Choose</option>
                                    <option value="page1"> Seite1 </option>
                                    <option value="page2"> Seite2 </option>
                                    </select>
                                </p>
                            </form>

                        </td>
                    </tr>
                    <tr>
                        <td height="20" bgcolor="#999999">&nbsp;</td>
                    </tr>
                    <tr>
                        <td height="350" id="result"></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>

<script>
    $('select').on('change', function() {
        $( "#result" ).load( "Subpages/" + $(this).val() + ".php" );
    });
</script>

</body>