我正在使用PHP浏览器检测并希望使用else if语句将它们重定向到依赖于浏览器的不同页面或包含某个文件..现在我正在采样重定向。
我收到语法错误,我很困惑,为什么,这是代码:
if($browser['name'] . $browser['version'] == "firefox" . "13.0.1"){
header("Location: newff.php");
elseif($browser['name'] . $browser['version'] != "firefox" . "13.0.1"){
header("Location: oldff.php");
} elseif($browser['name'] . $browser['version'] == "msie" . "13.0.1") {
header("Location: newie.php");
} elseif($browser['name'] . $browser['version'] != "msie" . "13.0.1") {
header("Location: oldie.php");
} elseif($browser['name'] . $browser['version'] == "chrome" . "20.0.1132.47"){
header("Location: newchrome.php");
} elseif($browser['name'] . $browser['version'] != "chrome" . "20.0.1132.47"){
header("Location: oldchrome.php");
} elseif($browser['name'] . $browser['version'] == "safari" . "534.57.2"){
header("Location: newsafari.php");
} elseif($browser['name'] . $browser['version'] != "safari" . "534.57.2") {
header("Location: oldsafari.php");
} else {
header("Location: other.php");
}
由于
本
答案 0 :(得分:5)
如果出现以下情况,您首先忘记使用右手曲柄:
if($browser['name'] . $browser['version'] == "firefox" . "13.0.1") {
header("Location: newff.php");
} // this is missing