我想知道是否可以复制:
if ($a = 1) {
header('Location: http://google.com');
exit;
} else {
header('Location http://yahoo.com');
exit;
}
使用速记?也许...
$a = 1 ? header('Location: http://google.com') : header('Location http://yahoo.com');
exit;
这似乎不起作用,这意味着我总是被重定向到谷歌。 =(
最佳答案
if ($a = 1) {
应该是
if ($a == 1) {
和
$a = 1 ?
应该是
$a == 1 ?
关于php - 在三元简写中使用 php header 重定向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14601151/