This forum is now read-only. Please use our new forums! Go to forums
It accepts a wrong code
Answer 51637ce3bff786888b000568
The instructions say write a comparison that returns true. 8 > 5 is true.
Answer 52c991de7c82ca5f5c006330
It gets worse. I passed typing in the following:
$var = 6; var < 7;
Here’s where PHP gets weird. So, ‘var’ is not the same thing as ‘$var’. ‘$var’ is a variable, and ‘var’ is a string. In PHP, strings have the numeric value of 0. (In Javascript, IIRC, strings have the numeric value of 1, so this is not a language-specific thing.) Technically, “var < 7” resolves to TRUE, even though we’re actually comparing apples and oranges.
It’s almost as if we gave computers syntax, but forgot to give them all the rules. I highly recommend comparing different data types, just to see what will happen. I already mentioned strings and integers; find some more!
2 comments
it makes perfect sense, don’t you know the rules of PHP? you use $ before the variable name to instruct that it is indeed a variable
Karl is quite correct.
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
2 comments
oh so what i have got there is right? lol
yes what you did was correct, but the instructions are incorrect, it wants a value less than 5 rather than greater (I believe it’s an error). It will give the value of true.