Skip to main content

//Relation Operator

Relation Operator


  1.  <?php 

  2. $a = 21;  // '$' use for variables
  3. $b = 10;

  4. //equal to
  5. if ($a == $b) // (a=21 == b=10) is False; Therefore a is not equal to b.
  6.              //the two given values are equal to each other then result will be True, Otherwise it returns False.
  7. {
  8. echo "a is equal to b"."<br>";
  9. else 
  10. {
  11. echo "a is not equal to b"."<br>"; //"echo" use for print line.
  12. }

  13. //grater than
  14. if ($a > $b) //(a=21 > b=10) is True; Therefore a is grater than b.
  15.             //the first value is grater than the second value then result will be True, Otherwise it returns False.
  16. {
  17. echo "a is greater than b"."<br>";
  18. else
  19. {
  20. echo "a is not greater than b"."<br>"; //"<br>" use for linebreak.
  21. }

  22. //less than
  23. if ($a < $b) //(a=21 < b=10) is False; Therefore a is not less than b.
  24.             //the first value is less than the second value then result will be True, Otherwise it returns False.
  25. {
  26. echo "a is less than b"."<br>";
  27. else // when If condition  flase then; else condition executed.
  28. {
  29. echo "a is not less than b"."<br>";
  30. }

  31. //grater than or equal to
  32. if ($a >= $b) //(a=21 >= b=10) is True; Therefore a is grater than or equal to b.
  33.              //the first value is grater than or equal to the second value then result will be True, Otherwise it returns False.
  34. {
  35. echo "a is greater than or equal to b"."<br>";
  36. else 
  37. {
  38. echo "a is not greater than equal to b"."<br>";
  39. }

  40. //less than equal to
  41. if ($a <= $b) //(a=21 <= b=10) is False; Therefore a is not less than or equal to  b.
  42.              //the first value is less than or equal to  the second value then result will be True, Otherwise it returns False.
  43.  {
  44. echo "a is less than or equal to b"."<br>";
  45. else 
  46. {
  47. echo "a is not less than or equal to b"."<br>";
  48. }
  49. ?>


👉Execute👈


//Output

/*

//equal to

a is not equal to b


//grater than

a is greater than b


//less than

a is not less than b


//greater than or equal to

a is greater than or equal to b


//less than or equal to

a is not less than or equal to b

*/


                                                 //ThE ProFessoR