What is the wrong here ?!


#1

<?php
$items = 5;

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

  ?>

#2

Try to remove the if statement inside the else statement that one if($items <= 5)


#3

The else statement is the catch all. It is executing when the IF conditions in this case ($items > 5) is false.

If you want multiple conditions to be evaluated and echo the "You get a 10% discount!" then you would use the elseif statement

if($items > 5) {
echo "You get a 10% discount!";
}
elseif ($items <= 5) {
echo "You get a 5% discount !";
}
else {
echo "You pay full price!";
}

?>