Greater Than and Less Than Operators in PHP

To check which value is greater, and which is smaller, the operators greater than >, greater than or equal to >=, less than <, and less than or equal to <= are used.

Let's study their work with a practical example. Suppose we have a variable $test with some value:

php<?php
  $test = 1;
?>

Let's check if the value of this variable is greater than zero or not:

php<?php
  $test = 1;
  
  if ($test > 0) {
    echo '+++'; // this will execute
  } else {
    echo '---';
  }
?>

Now let's change the variable value to a negative one:

php<?php
  $test = -1; // change the variable value
  
  if ($test > 0) {
    echo '+++';
  } else {
    echo '---'; // this will execute
  }
?>

Now suppose the variable value is 0. In this case, we will end up in the else block, because our condition states that the variable $test must be strictly greater than zero:

php<?php
  $test = 0;
  
  if ($test > 0) {
    echo '+++';
  } else {
    echo '---'; // this will execute
  }
?>

Let's change the condition to greater than or equal to:

php<?php
  $test = 0;
  
  if ($test >= 0) {
    echo '+++'; // this will execute
  } else {
    echo '---';
  }
?>
Задание 1

Check that the variable $test is greater than 10.

Задание 2

Check that the variable $test is less than 10.

Задание 3

Check that the variable $test is greater than or equal to 10.

Задание 4

Check that the variable $test is less than or equal to 10.