Articles HTML Tutorial CSS Tutorial JavaScript Tutorial PHP Tutorial MYSQL Tutorial Contact Us
PHP If Else

If Else statements allow you to check if a certain condition is true, and do something, and if it's not true, do something else instead.

You can use the if statement on it's own: <?PHP
$condition=true;

if($condition){
echo 'Condition is True';
}
?>

Or you can use the if statement with an else statement: <?PHP
$condition=true;

if($condition){
echo 'Condition is True';
}
else{
echo 'Condition is False';
}
?>

You can even combine if & else statements together: <?PHP
$condition='c';

if($condition=='a'){
echo 'Condition is A';
}
else if($condition=='b'){
echo 'Condition is B';
}
else{
echo 'Condition is C';
}
?>


There's not a lot else to discuss regarding if else... it's that simply, and you'll use them alot!