User Tools

Site Tools


programmieren:grundlagen:logical_operators

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
programmieren:grundlagen:logical_operators [2026/11/10 15:58] – [Comparison] created adminprogrammieren: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???, returns an int indicating if value is bigger, smaller or equal to other value // Spaceship???, returns an int indicating if value is bigger, smaller or equal to other value
  
-<code php> 
 $a = 50; $a = 50;
 $b = 30; $b = 30;
Line 210: Line 202:
 </code> </code>
  
 +===== 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 
 + 
 +</code> 
 + 
 +===== String ===== 
 + 
 +<code php> 
 + 
 +// Concatenation 
 + 
 +$a = 'Foo'; 
 +$b = 'bar'; 
 + 
 +$a = $a . $b; // $a = 'Foobar' 
 + 
 +// Assignment 
 + 
 +$a .= $b; // $a = 'Foobar' 
 + 
 +</code> 
 + 
 +===== Array ===== 
 + 
 +<code php> 
 +// Union 
 + 
 +$a = ["a" => "apple", "b" => "banana"]; 
 +$b = ["a" => "pear", "b" => "strawberry", "c" => "cherry"]; 
 + 
 +$c = $a + $b; // $c = ["a" => "apple", "b" => "banana", "c" => "cherry"]. Any keys that already exist in the previous array are ignored 
 +</code> 
 + 
 +===== 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 
 + 
 +</code>
  
programmieren/grundlagen/logical_operators.1794322710.txt.gz · Last modified: by admin · Currently locked by: 216.73.217.145

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki