【发布时间】:2018-04-28 17:59:55
【问题描述】:
我遇到了一个小问题。如果参数无效,我想安全地包含基于来自子目录 + 句柄的 $_GET 参数的文件。
<?php
if(isset($_GET['p']) && $_GET['p'] == 'fahrzeuge'){
include 'includes/cars.php';
}
if(isset($_GET['p']) && $_GET['p'] == 'impressum'){
include 'includes/impressum.php';
}
if(isset($_GET['p']) && $_GET['p'] == 'home'){
include 'includes/home.php';
}
if(isset($_GET['p']) && $_GET['p'] == 'anfahrt'){
include 'includes/anfahrt.php';
}
if(isset($_GET['p']) && $_GET['p'] == 'about'){
include 'includes/about.php';
}
?>
这是我的代码。对不起,我知道这是解决这个问题的一种菜鸟方式。我该如何改进它?任何建议/帮助将不胜感激
【问题讨论】: