解析错误:语法错误,意外T_ELSEIF [英] Parse error: syntax error, unexpected T_ELSEIF

查看:1270
本文介绍了解析错误:语法错误,意外T_ELSEIF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在codeacademy上做了一些非常基本的编码,这已经让我烦恼了一个多小时。
这段代码可能有错误,它显示错误解析错误:语法错误,第12行出现意外的T_ELSEIF

 < HTML> 
< head>
< title>我们的商店< / title>
< / head>
< body>
< p>
<?php
$ items = 10; //将此值设置为大于5的数字!
if($ items> 5){
echo你可以享受10%的折扣! }
else {echo你可以享受5%的折扣!;
} elseif($ items == 1){
echoSorry,no discount!;
}


?>
< / p>
< / body>
< / html>


解决方案

else 块必须是最后一个。它不能在之前,否则如果

  if($ items> ; 5){
echo你可以享受10%的折扣!;
} else if($ items == 1){
echoSorry,no discount!;
}其他{
echo你得到5%的折扣!;
}


Doing some very basic coding on codeacademy and this has been bugging me for over an hour now. What is possibly wrong with this code that it is displaying the error " Parse error: syntax error, unexpected T_ELSEIF on line 12 "

<html>
  <head>
    <title>Our Shop</title>
  </head>
  <body>
    <p>
      <?php
        $items = 10;    // Set this to a number greater than 5!
        if ($items > 5) {
          echo "You get a 10% discount!"; }
          else { echo "You get a 5% discount!";
          } elseif ($items == 1) {
              echo "Sorry, no discount!";
          }


      ?>
    </p>
  </body>
</html>

解决方案

The else block must be last. It cannot go before an else if:

if ($items > 5) {
    echo "You get a 10% discount!";
} else if ($items == 1) {
    echo "Sorry, no discount!";
} else {
    echo "You get a 5% discount!";
}

这篇关于解析错误:语法错误,意外T_ELSEIF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆