Open phparithmetic.php and save it as phpif.php.  Delete the last two lines (of the four lines of code).

Sometimes you need to do different things depending on the value of a variable (or something else). Add this to the PHP page you already have (phpif.php) under the existing two lines:

if ($firstValue==$secondValue) {
    echo "<p>the values are the same</p>";
}

The if statement is much the same as a JavaScript one and has this structure:

if something is true

    do this

The condition is inside normal brackets.  If the condition is met (is true) the code inside the braces runs.  Remember the use of the == operator. This is used because = means to "set something equal to something else". Double equals means to compare the two things.

Upload the page and try it. Nothing should happen because the condition failed (is not true). Change the values for the variables on the first two lines of code to make them the same. Upload and try again.  This time it should say they are the same.

Less than and greater than

Copy the whole if statement including the braces and the code (three lines) and paste it under itself.  Replace the text in the paragraph with The first value is less than the second value.  To check if a value is less than another replace the condition in the second if statement with this:

$firstValue<$secondValue

Upload and try.  Change the values to see what happens with different numbers to compare.

Greater than uses the > symbol.   Again copy and paste the if and try it with various values (remember to change the paragraph text).

You can also check if something is less than or equal to so copy the if again and replace the condition in the new one with this:

$firstValue<=$secondValue

Greater than or equal to works the same way.  Try them both with different numbers.

NOT

You can also use negative conditions such as this one (copy and paste the if statement again and replace the condition and the paragraph text):

$firstValue!=$secondValue

This means "is not equal to".