If, Else, and Elseif statements are very important! Without them as well as logical and comparison operators, you site would not be very clever at all! We'll start by taking a look at the if statement, the most important of all statements! If statements allow you to program:
If x is true, then do y
If x is false, then skip x
The syntax of If looks like this:
if (condition) {
//any PHP here gets executed
}
Below is an example if a PHP If statement:
<?php
$Day = "Monday"; // set variable
if ($Day == "Monday") {
print ("Monday's suck!");
}
?>
An important this to learn about the operators = and == is that they are totally different!
if ($Day = "Monday") and if ($Day == "Monday")
The operator = means that $Day will be set as Monday, whereas, == should be read as "becomes equal to" - The value of $Day becomes equal to "Monday". We will look at these more closely in a later PHP tutorial.