➤ The if...else statement executes some code if a condition is true and another code if that condition is false. For instance:
$x = 10;
if ($x > (2+4)) {
	echo "Condition is True !\n";
} else {
	echo "Condition is False !\n";
} // outputs: Condition is True !


if ($x < (2+4)) {
	echo "Condition is True !\n";
} else {
	echo "Condition is False !\n";
} // outputs: Condition is False !


$my_age = 19;
if ($my_age >= 18 ) {
	echo "I am adult!";
} else {
	echo "I am child!";
} // outputs: I am adult!
by Levani Makhareishvili
2 years ago
PHP
If...else statement
1
Pro tip: use ```triple backticks around text``` to write in code fences