PHP If Compare Statements
PHP "if" statements are used to set up conditional operations for events to occur if certain conditions are or are not met. These "if" statements come in a few different flavors and are used in different situations, depending on your need.
-
Greater Than Comparison
-
To evaluate if a value ($var1) is greater than another value ($var2), use the "greater than" symbol, like so:
if($var1 > $var2)
Less Than Comparison
-
To evaluate if a value ($var1) is less than another value ($var2), use the "less than" symbol, like so:
if($var2 < $var1)
-
Equality Comparison
-
To evaluate if two values ($var1 and $var2) are equal to each other, use the equality symbol (two equal signs), like so:
if($var1 == $var2)
Not Equal Comparison
-
Set up a condition that triggers if two values ($var1 and $var2) are not equal to each other like so:
if($var1 != $var2)
-