作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我看过几个“PHP 重定向不起作用......”的帖子,但我没有运气弄清楚我的问题是怎么回事。
下面的代码总是转到 teacherActivity_2.php
即使第二个 if 通过并且应该重定向到 teacherActivity_3_shadowT.php
.如果我注释掉 teacherActivity_2.php
,页面重定向(如预期)到 teacherActivity_3_shadowT.php
.我想我错过了一些我应该知道但不知道的晦涩规则。有任何想法吗?
为什么这会重定向到 teacherActivity_2.php
而不是 teacherActivity_3_shadowT.php
?
if($test == 'yes') {
if($_SESSION['wblReporting']['activity'] == 'shadowT'){
header('Location: /app/do_cte-wbl/forms/teacherActivity_3_shadowT.php');
}
header('Location: /app/do_cte-wbl/forms/teacherActivity_2.php');
}
?>
最佳答案
请尝试以下操作:
if($test == 'yes') {
if($_SESSION['wblReporting']['activity'] == 'shadowT'){
header('Location: /app/do_cte-wbl/forms/teacherActivity_3_shadowT.php');
die();
} else {
header('Location: /app/do_cte-wbl/forms/teacherActivity_2.php');
die();
}
}
关于PHP 重定向在嵌套 IF 语句中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60107690/
我是一名优秀的程序员,十分优秀!