You can use the if….else statement to execute some code if a condition is true and another code if a condition is false.

Syntax:

if (condition)
{
code to be executed if condition is true;

}
else
{
code to be executed if condition is false;
}

Example:
Code:

$p=4;
$q=7;
if ($p > $q) {
    echo "p is bigger than q";
} else {
    echo   "p is NOT bigger than q";
}

Output:

p is NOT bigger than q

eXTReMe Tracker