Parse Error: Syntax Error, Unexpected T_elseif
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:
Solution 1:
The else
block must be last. It cannot go before an else if
:
if ($items > 5) {
echo"You get a 10% discount!";
} elseif ($items == 1) {
echo"Sorry, no discount!";
} else {
echo"You get a 5% discount!";
}
Solution 2:
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!";
} elseif ($items == 1) {
echo"Sorry, no discount!";
} else {
echo"You get a 5% discount!";
}
?></p></body></html>
Post a Comment for "Parse Error: Syntax Error, Unexpected T_elseif"