php-如何将此 IF 条件放入开关内?
请帮助我更正此代码,我想将 if 放在开关内:
switch ($urlcomecatid) {
if ($urlcomeparentid == 1 || $urlcomeparentid == 2 || $urlcomeparentid == 3)
break;
case "50":
case "51":
case "52":
case "109":
case "110":
//do nothing and exit from switch
break;
default:
header ("Location:http://www.example.com/tech/tech.php"); exit();
break;
}
Please help me for correcting this code,i want put if inside switch:
switch ($urlcomecatid) {
if ($urlcomeparentid == 1 || $urlcomeparentid == 2 || $urlcomeparentid == 3)
break;
case "50":
case "51":
case "52":
case "109":
case "110":
//do nothing and exit from switch
break;
default:
header ("Location:http://www.example.com/tech/tech.php"); exit();
break;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正确的代码应该是这样的
The correct code should be something like
使用
if
而不是switch
。您应该避免
exit()
因为它会杀死脚本的其余部分,这在调试时是潜在的问题来源。Use an
if
instead of theswitch
.You should avoid
exit()
as it kills the rest of your script which is a potential source of problems when you debug.