This tutorial will show the main operators that can be used in PHP for: sum, multiplication, divison, equalities, logic operators and so on.
Arithmetic operators :
$a + $b
$a – $b
$a * $b
$a / $b
For mod we can use $a % $b, which gives us the rest of $a divided to $b.
Attribution operators :
Operators used for comparison :
Logic operators :
NOT: !$a returns TRUE if $a is FALSE.
AND: $a && $b returns TRUE if $a and $b are TRUE, FALSE otherwise.
You can use also the keyword and instead of &&.
OR: $a || $b returns TRUE if $a or $b are TRUE.
You can use also the keyword or instead of ||.
XOR: $a xor $b returns TRUE if $a or $b are TRUE, but not both in the same time.
Multiple operators :
Incremenation and decremantation :
Thanks for reading this PHP tutorial !
Leave a Reply