【发布时间】:2012-11-30 02:27:50
【问题描述】:
我有很多php 文件。
访问每个php我正在使用参数。
例如:index.php?route=changepassword、index.php?route=aboutus 等
我有一个route.php 将参数链接到正确的文件
更好用
If-Else statement
$route = $_GET['route'];
if ($route==changepassword) {
//statement
} else if ($route==aboutus) {
//statement
}
使用switch-case?
$route = $_GET['route'];
switch ($route) {
case "changepassword" :
//statement
break;
case "aboutus" :
//statement
break;
}
这只是2个文件,我有10+个文件,用什么比较好?
【问题讨论】:
-
没有比这更好的了。只有 Zuul。
-
切换 IMO。更易于阅读、编写和维护。
-
"if" versus "switch"的可能重复
标签: php