In PHP, we can make decisions on our codes with if. We need a condition for the if statement that means we need the code we want it to do as a result of the condition.

The basic form of If is:

<?php
if (condition) {
// codes to work if the condition is positive
}
?>

Let’s explain and show with an example:

<?php
$a = 20;
if ($a > 10) {
    echo 'variable is greater than 10';
}
?>

We first set the value 20 to the variable $a, and then we said with if, “Run the following codes if the variable $a is greater than 10”. So in this case, the screen will say “variable a is greater than 10”. If we put the value 5 in the $a variable, nothing would be written on the screen.