Complete the code to check if a number is positive.
<?php $number = 5; if ($number [1] 0) { echo "Positive number"; } ?>
The condition $number > 0 checks if the number is greater than zero, meaning it is positive.
Complete the code to print 'Even' if the number is even.
<?php $number = 4; if ($number % 2 [1] 0) { echo "Even"; } ?>
The condition $number % 2 == 0 checks if the remainder when dividing by 2 is zero, meaning the number is even.
Fix the error in the condition to check if a number is negative.
<?php $number = -3; if ($number [1] 0) { echo "Negative number"; } ?>
The condition $number < 0 correctly checks if the number is less than zero, meaning negative.
Fill both blanks to create a condition that checks if a number is between 1 and 10.
<?php $number = 7; if ($number [1] 1 && $number [2] 10) { echo "Number is between 1 and 10"; } ?>
The condition $number >= 1 && $number <= 10 checks if the number is at least 1 and at most 10.
Fill all three blanks to create a condition that checks if a number is positive, even, and less than 20.
<?php $number = 16; if ($number [1] 0 && $number % 2 [2] 0 && $number [3] 20) { echo "Number is positive, even, and less than 20"; } ?>
The condition checks three things: number greater than zero, number even (remainder zero), and number less than 20.