The simplest form of a PHP if else statement is as below.
if (a==b)
Do this;
else
Do this;
Note that the statements immediately following the if or else statement are executed. If you want to execute a chunk of codes conditionally then you should include the code inside braces as given in the example below.
if (a==b) <-- Condition inside the braces
{
PHP Statement 1;
PHP Statement 2;
}
else
{
PHP Statement 3;
PHP Statement 4;
}
What if more than one statements are there? In that scenario you should use the else if statements as explained below.