humanware

php_training_day3_increment_decrement

Aug 7th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <?php
  2. /*
  3.  
  4. INCREMENT OPERATORS
  5. ++ $x   Pre-Increment Operator      Increment $x by one then return result
  6. $x ++   Post-Increment Operator     Return the value of $x and increment of the value of $x
  7.  
  8. DECRENT OPERATOR
  9. -- $x   Pre Decrement Operator      Decrement $x by one then return result
  10. $x --   Post Decrement Operator     Return the value of $x then decrement
  11.  
  12. $x = 10;
  13. echo ++$x;
  14. echo $x++ . '<br />';
  15. echo --$x;
  16. echo '<br />';
  17. echo $x-- . '<br />';
  18. echo $x;
  19. */
  20.  
  21. /* LOGICAL OPERATORS
  22. Logical operators are used to combine two conditional statements
  23.  
  24. AND    Returns True if both $x & $y are true
  25. OR     Returns True either $x or $y is true
  26. XOR    Returns True if either $x or $y is true but not both
  27. &&     Returns True if both $x & $y are true
  28. ||     Returns True either $x or $y is true
  29. !      True if $x is not true
  30. */
  31. $a = true && true;
  32. var_dump($a);
  33. $b = true && false;
  34. var_dump($b);
  35. $c = false && false;
  36. var_dump($c);
  37. $a = true || false;
  38. var_dump($a);
  39. $b = true || true;
  40. var_dump($b);
  41. $c = false || false;
  42. var_dump($c);
Advertisement
Add Comment
Please, Sign In to add comment