programmieren:grundlagen:logical_operators
This is an old revision of the document!
Table of Contents
Logical operators
Increment
++$a // Pre increments it, returns first then increments $a++ // Post increments it, increments and then returns --$a // Same but decrement $a-- // Same but decrement
Assignment
$a; $a = 5; // = is used as an asigning operator // Arithmetic assignment $a = 2; $b = 2; $a += $b; // $a is now equal to 4, also works with all other arithmetic operations // Concatenation $a = 'hel'; $b = 'lo'; $a .= $b; // $a is now equal to 'Hello' // Null coalesence $a = null; $b = 4; $a ??= $b; // Incase $a is null it now equals $b // Assignment with booleans $a = true and false // Assignment operator is stronger and $a equals true $b = (true and false) // Condition is stronger and $b equals false
Comparison
// Is equal $a = 50; $b = 30; $a == $b; // False $a = 50; $b = 50; $a == $b; // True $a = 1; $b = true; $a == $b; // True // Is identical <code php> $a = 50; $b = 30; $a === $b; // False $a = 50; $b = 50; $a === $b; // True $a = 1; $b = true; $a === $b; // False // Is not equal <code php> $a = 50; $b = 30; $a != $b; // True $a = 50; $b = 50; $a != $b; // False $a = 1; $b = true; $a != $b; // False // Is not identical <code php> $a = 50; $b = 30; $a !== $b; // True $a = 50; $b = 50; $a !== $b; // False $a = 1; $b = true; $a !== $b; // True // Is less than <code php> $a = 50; $b = 30; $a < $b; // False $a = 50; $b = 50; $a < $b; // False $a = 30; $b = 50; $a < $b; // True // Is greater than <code php> $a = 50; $b = 30; $a > $b; // True $a = 50; $b = 50; $a > $b; // False $a = 30; $b = 50; $a > $b; // False // Is less than or equal to <code php> $a = 50; $b = 30; $a <= $b; // False $a = 50; $b = 50; $a <= $b; // True $a = 30; $b = 50; $a <= $b; // True // Is greater than or equal to <code php> $a = 50; $b = 30; $a >= $b; // True $a = 50; $b = 50; $a >= $b; // True $a = 30; $b = 50; $a >= $b; // False // Spaceship???, returns an int indicating if value is bigger, smaller or equal to other value <code php> $a = 50; $b = 30; $a <=> $b; // 1 $a = 50; $b = 50; $a < $b; // 0 $a = 30; $b = 50; $a < $b; // -1
I should totally expand this list
programmieren/grundlagen/logical_operators.1794322730.txt.gz · Last modified: by admin
