+ 2

What's the error in this code

<?php $num = 65; if ($num =<2) echo "Infant"; elseif ($num>2 and $num<5) { echo "Toddler"; } elseif ($num>5 and $num<12) { echo "Adolescent"; } elseif ($num>12 and $num<19) { echo "Teenager"; } else { echo "Adult" } ?>

23rd Jun 2018, 6:37 AM
codeAddict
codeAddict - avatar
4 Answers
+ 4
1) '$num =< 2' ----> '$num <= 2' 2) after 'echo "adult"' you're missing a ';'
23rd Jun 2018, 6:46 AM
The Coding Sloth
The Coding Sloth - avatar
+ 5
line 3 : if ($num <= 3) line 19: echo "adult" ; in line 3 use <= instead of =< in line 19 you missed the semicolon ( ; )
23rd Jun 2018, 6:46 AM
Nikhil Dhama
Nikhil Dhama - avatar
+ 1
Thanks. Problem solved.
23rd Jun 2018, 11:00 AM
codeAddict
codeAddict - avatar