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. } 
  10. else 
  11. {
  12. echo "a is not equal to b"."<br>"; //"echo" use for print line.
  13. }

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

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

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

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


👉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