Guest User

Untitled

a guest
Jul 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. $a = false;
  2. $b = false;
  3. $c = 'sometext';
  4. $result = $a or $b or $c or exit('error: all variables are false');
  5.  
  6. // This has the same effect:
  7. $result = $a or $b or $c;
  8.  
  9. // As this:
  10. $result = $a;
  11. $a or $b or $c; // this has no effect
  12.  
  13. // These all have the same effect:
  14.  
  15. $result = ($a or $b or $c);
  16. $result = $a || $b || $c;
  17.  
  18. if ($a or $b or $c)
  19. $result = true;
  20. else
  21. $result = false;
  22.  
  23. if ($a || $b || $c)
  24. $result = true;
  25. else
  26. $result = false;
  27.  
  28. $a = false;
  29. $b = false;
  30. $c = 'sometext';
  31. $result = array_filter(array($a, $b, $c));
  32.  
  33. var_dump($result);
  34.  
  35. array(1) {
  36. [2]=>
  37. string(8) "sometext"
  38. }
  39.  
  40. ($result = $a) || ($result = $b) || ($result = $c) || exit("no");
  41.  
  42. (($result = $a) !== false) || (($result = $b) !== false) || (($result = $c) !== false) || exit("no");
  43.  
  44. if ($a !== false)
  45. $result = $a;
  46. elseif ($b !== false)
  47. $result = $b;
  48. elseif ($c !== false)
  49. $result = $c;
  50. else
  51. exit("no");
  52.  
  53. foreach(array('a','b','c') as $key)
  54. if (($result = $$key) !== false)
  55. break;
  56. if ($result === false)
  57. exit("no");
  58.  
  59. $a = false;
  60. $b = false;
  61. $c = 'sometext';
  62. $result = null;
  63.  
  64. foreach(array('a', 'b', 'c') as $k)
  65. {
  66. if($$k !== false)
  67. {
  68. $result = $$k;
  69. break;
  70. }
  71. }
Add Comment
Please, Sign In to add comment