Relational Operators in PHP
Notes:
PHP Relational Operators
Relational operators are also known as comparison operators. They are used find the relationship between two values or compare the relationship between two values; on comparison they yield the result true (1) or false (0).
< : less than
> : greater than
<= : less than or equal to
>= : greater than or equal to
== : equal to
=== : strictly equal to
!= : not equal to
<> : not equal to
!== : strictly not equal to
Example Code:
echo (3 < 4) ? "true" : "false", "<br/>"; // true
echo (4 < 3) ? "true" : "false", "<br/>"; // false
echo (4 > 3) ? "true" : "false", "<br/>"; // true
echo (4 > 5) ? "true" : "false", "<br/>"; // false
echo (5 <= 6) ? "true" : "false", "<br/>"; // true
echo (6 <= 6) ? "true" : "false", "<br/>"; // true
echo (7 <= 6) ? "true" : "false", "<br/>"; // false
echo (7 >= 6) ? "true" : "false", "<br/>"; // true
echo (7 >= 7) ? "true" : "false", "<br/>"; // true
echo (7 >= 8) ? "true" : "false", "<br/>"; // false
echo (9 == 9) ? "true" : "false", "<br/>"; // true
echo (9 == "9") ? "true" : "false", "<br/>"; // true
echo (9 === "9") ? "true" : "false", "<br/>"; // false
echo (9 != 9) ? "true" : "false", "<br/>"; // false
echo (9 != "9") ? "true" : "false", "<br/>"; // false
echo (9 !== "9") ? "true" : "false", "<br/>"; // true
echo (9 <> 10) ? "true" : "false", "<br/>"; // true
Interview Questions:
1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a