首页 > 解决方案 > ( ! ) 解析错误:语法错误,第 121 行 D:\Yatharth Files\wamp\www\index.php 中的意外 '{'

问题描述

为什么这段代码会抛出错误?

<?php
if(isset($_POST['aca'])){
    header("location:Academic");
}elseif(isset($_POST['ed'])){
    header("location:EnjoyDev");
}elseif(isset($_POST['hb'])){
    header("location:Hoverboard");
}elseif(isset($_POST['lc'])){
    header("location:LiveChat");
}elseif(isset($_POST['mp']){
    header("location:myPro");
}elseif(isset($_POST['ym'])){
    header("location:YatMath");
}
?>

第 121 行:}elseif(isset($_POST['mp']){
我没有错过任何分号。

标签: php

解决方案


第 121 行:

}elseif(isset($_POST['mp']){

应该

} elseif( isset($_POST['mp']) ) {

另外,我建议您使用空格来提高代码的可读性。那时你就不会犯这个错误了。


推荐阅读