programmieren:grundlagen:logical_operators
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| programmieren:grundlagen:logical_operators [2026/11/10 15:58] – [Comparison] created admin | programmieren:grundlagen:logical_operators [2026/11/12 16:36] (current) – Added Types and Array admin | ||
|---|---|---|---|
| Line 46: | Line 46: | ||
| ===== Comparison ===== | ===== Comparison ===== | ||
| + | <code php> | ||
| // Is equal | // Is equal | ||
| - | <code php> | ||
| $a = 50; | $a = 50; | ||
| $b = 30; | $b = 30; | ||
| Line 66: | Line 66: | ||
| // Is identical | // Is identical | ||
| - | <code php> | ||
| $a = 50; | $a = 50; | ||
| $b = 30; | $b = 30; | ||
| Line 84: | Line 83: | ||
| // Is not equal | // Is not equal | ||
| - | <code php> | ||
| $a = 50; | $a = 50; | ||
| $b = 30; | $b = 30; | ||
| Line 102: | Line 100: | ||
| // Is not identical | // Is not identical | ||
| - | <code php> | ||
| $a = 50; | $a = 50; | ||
| $b = 30; | $b = 30; | ||
| Line 120: | Line 117: | ||
| // Is less than | // Is less than | ||
| - | <code php> | ||
| $a = 50; | $a = 50; | ||
| $b = 30; | $b = 30; | ||
| Line 138: | Line 134: | ||
| // Is greater than | // Is greater than | ||
| - | <code php> | ||
| $a = 50; | $a = 50; | ||
| $b = 30; | $b = 30; | ||
| Line 156: | Line 151: | ||
| // Is less than or equal to | // Is less than or equal to | ||
| - | <code php> | ||
| $a = 50; | $a = 50; | ||
| $b = 30; | $b = 30; | ||
| Line 174: | Line 168: | ||
| // Is greater than or equal to | // Is greater than or equal to | ||
| - | <code php> | ||
| $a = 50; | $a = 50; | ||
| $b = 30; | $b = 30; | ||
| Line 192: | Line 185: | ||
| // Spaceship???, | // Spaceship???, | ||
| - | <code php> | ||
| $a = 50; | $a = 50; | ||
| $b = 30; | $b = 30; | ||
| Line 210: | Line 202: | ||
| </ | </ | ||
| + | ===== Logical ===== | ||
| - | I should totally expand this list | + | <code php> |
| + | $a = true; | ||
| + | $b = false; | ||
| + | |||
| + | $a and $b // False | ||
| + | |||
| + | $a or $b // True | ||
| + | |||
| + | $a xor $b // True | ||
| + | |||
| + | $a && $b // False | ||
| + | |||
| + | $a || $b // True | ||
| + | |||
| + | $a = true; | ||
| + | $b = true; | ||
| + | |||
| + | $a and $b // True | ||
| + | |||
| + | $a or $b // True | ||
| + | |||
| + | $a xor $b // False | ||
| + | |||
| + | $a && $b // True | ||
| + | |||
| + | $a || $b // True | ||
| + | |||
| + | $a = false; | ||
| + | $b = false; | ||
| + | |||
| + | $a and $b // False | ||
| + | |||
| + | $a or $b // False | ||
| + | |||
| + | $a xor $b // False | ||
| + | |||
| + | $a && $b // False | ||
| + | |||
| + | $a || $b // False | ||
| + | |||
| + | // Symbols take presedence over words | ||
| + | |||
| + | </ | ||
| + | |||
| + | ===== String ===== | ||
| + | |||
| + | <code php> | ||
| + | |||
| + | // Concatenation | ||
| + | |||
| + | $a = ' | ||
| + | $b = ' | ||
| + | |||
| + | $a = $a . $b; // $a = ' | ||
| + | |||
| + | // Assignment | ||
| + | |||
| + | $a .= $b; // $a = ' | ||
| + | |||
| + | </ | ||
| + | |||
| + | ===== Array ===== | ||
| + | |||
| + | <code php> | ||
| + | // Union | ||
| + | |||
| + | $a = [" | ||
| + | $b = [" | ||
| + | |||
| + | $c = $a + $b; // $c = [" | ||
| + | </ | ||
| + | |||
| + | ===== Types ===== | ||
| + | |||
| + | <code php> | ||
| + | // instanceof | ||
| + | |||
| + | class ParentClass {} | ||
| + | class MyClass extends ParentClass {} | ||
| + | class NotMyClass {} | ||
| + | |||
| + | $a = new MyClass; | ||
| + | $b = new NotMyClass; | ||
| + | $c = new ParentClass; | ||
| + | |||
| + | $a instanceof MyClass // True | ||
| + | $a instanceof NotMyClass // False | ||
| + | $a instanceof ParentClass // True, works with any kind of inheritance | ||
| + | |||
| + | $b instanceof MyClass // False | ||
| + | $b instanceof NotMyClass // True | ||
| + | $b instanceof ParentClass // False | ||
| + | |||
| + | $c instanceof MyClass // False | ||
| + | $c instanceof NotMyClass // False | ||
| + | $c instanceof ParentClass // True | ||
| + | |||
| + | </ | ||
programmieren/grundlagen/logical_operators.1794322710.txt.gz · Last modified: by admin · Currently locked by: 216.73.217.145
