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 positive.
Complete the code to check if a number is zero or not.
<?php $number = 0; if ($number [1] 0) { echo "Number is zero"; } else { echo "Number is not zero"; } ?>
The condition $number == 0 checks if the number equals zero.
Fix the error in the if statement 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 negative.
Fill both blanks to create a condition that checks if a number is between 1 and 10 (inclusive).
<?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 between 1 and 10, including both ends.
Fill all three blanks to create an if-else statement that prints if a number is positive, zero, or negative.
<?php $number = [1]; if ($number [2] 0) { echo "Positive number"; } elseif ($number [3] 0) { echo "Zero"; } else { echo "Negative number"; } ?>
The variable $number is set to 5. The first condition $number > 0 checks for positive numbers. The second condition $number == 0 checks for zero.