Parse error: syntax error, unexpected T

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!";
}

Your else block needs to be the last if you intend to use else if . Please watch your use of { and } as well. If it's messy, it's hard to read and harder to debug.

<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 if ($items == 1) {
            echo "Sorry, no discount!"; 
        } else { 
            echo "You get a 5% discount!";
        }
      ?>
    </p>
  </body>
</html>
链接地址: http://www.djcxy.com/p/12020.html

上一篇: PHP,解析错误:语法错误,意外的T

下一篇: 解析错误:语法错误,意外的T