User Tools

Site Tools


programmieren:grundlagen:logical_operators

This is an old revision of the document!


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

I should totally expand this list

programmieren/grundlagen/logical_operators.1793978707.txt.gz · Last modified: by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki