This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Conditionals and Control Flow Forum

View Course » View Exercise

635 points
B8e16bcc7c65421391e74d673654cba8?s=140&d=retro
Submitted by
Taylor Augustin
over 4 years ago

code works but won't pass

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

This code makes the correct statement display, but it wont let me pass.
I had the same problem with the last section 'Your first if' where the code works but i wasnt allowed to pass the section.


1 vote

permalink

<?php
    $items = 9;
    if ($items > 5){
      echo "You get a 10% discount!";
    } else {
        echo "You get a 5% discount!";
    } //Working code
  ?>

Working code.

861 points
5225c4e1abf821eb75006519_81510258
Submitted by
Renan Zapelini
about 4 years ago


1 vote

permalink

<html>

<?php
$items = 9;
if ($items >= 5) {
print "The condition is false";
} else {
print "You get a 5% discount!";
}
// prints "Who are you?"
?>

83 points
E85c27806fd94f1a05a919e80d6a8347?s=140&d=retro
Submitted by
Code_Killer_17
over 3 years ago


0 votes

permalink

some of these lessons require exact strings. Do you need to add an "!" at the end of the 10% discount line?

1203 points
C2f977210db628cd78013998f8b1b974?s=140&d=retro
Submitted by
thebaron
over 4 years ago

1 Comment

52087f36548c355940006eaf_853295980 Zack Mozawskii over 4 years ago

(y)


0 votes

permalink

You need to put echo instead of print. Print is for Python!!

683 points
51411ce8c01c85bcd300152f_944965203
Submitted by
jonah eng
over 3 years ago


0 votes

permalink

I had the same issue but It's because you have to tell it to echo "The condition is false" not print "You get a 5% discount!"; or whatever else you're having the false condition echo.

263 points
5922f152836966b39f0003fd_202114961
Submitted by
Ryan Ruud
over 3 years ago