PHP – Comparison Operators

Comparison Operators allow you to compare variable values against values to determine whether an event should trigger.  You use Comparison Operators in Loops and If Statements.

<?php

$name = "bob";
$age = 25;

if ($name == 'bob') {
	print "Hello Sir";
} elseif ($name == 'sue') {
	print "Hello Mam";
} else {
	print "Who are you?";
}

print "<br>";

if ($age >= 18) {
	print "You Can Enter";
} else {
	print "You CANNOT Enter";
}

?>

Be the first to comment

Leave a Reply