You can use the if….elseif…else statement to select one of several blocks of code to be executed.

Syntax:

if (condition)
{
code to be executed if condition is true;
}
elseif (condition)
{
if condition is true;
}
else
{
code to be executed if condition is false;
}

Example:
Code:

$p=5;
$q=8;
if ($p > $q) {
    echo "p is bigger than ";
} elseif ($p == $q) {
    echo "p is equal to q";
} else {
    echo "p is smaller than q";
}

Output:

p is smaller than q

eXTReMe Tracker