Advertisement
shuvocse

PHP Conditional Logic And Operator

Aug 29th, 2020
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <?php
  2.  
  3. $n = 12;
  4. if ($n % 2 == 0){
  5.     echo "$n is a even number";
  6. }else{
  7.     echo "$n is a odd number";
  8. }
  9.  
  10. echo "<br/>";
  11.  
  12. if ($n > 10) {
  13.     echo "$n is greater then 10";
  14. }
  15.  
  16.  
  17. echo "<br/>";
  18.  
  19.  
  20. $m = 12;
  21. $s = 13;
  22.  
  23. if ($m != $s) {
  24.     echo "M is qual to N";
  25. }else{
  26.     echo "M is not equal to N";
  27. }
  28.  
  29.  
  30.  
  31. echo "<br/>";
  32.  
  33.  
  34. $age = 13;
  35.  
  36. if ($age >= 13 && $age <=19) {
  37.     echo "This is a teenager";
  38. }else{
  39.     echo "this person not a teenager";
  40. }
  41.  
  42.  
  43. echo "<br/>";
  44.  
  45.  
  46. $food = "salmon";
  47.  
  48. if ("tuna" == $food || "salmon" == $food) {
  49.     echo "{$food} has vitamin D";
  50. }elseif ("apple"==$food) {
  51.     echo "Apple dose not contain vitamin D";
  52. }else{
  53.     echo "we dont know if {$food} contain vitamin D";
  54. }
  55.  
  56.  
  57. // Operator
  58.  
  59. /*==
  60. !=
  61. >
  62. <
  63. =>
  64. >=
  65. &&
  66. ||*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement