PHP Lessons

PHP operators

In order to operate on the variables, we can use arithmetical, comparison or boolean operators.

operator
PHP code
type of variable
assignment$a = "pluto";any variable
addition $a = $b + $c;numerical
subtraction$a = $b - $c;numerical
multiplication$a = $b*$c;numerical
division$a = $b/$c;numerical
modulus (remainder of the division)$a = $b%$c;numerical
increment by 1 $a++; it's the same as $a = $a + 1;numerical
decrement by 1$a--; it's the same as $a = $a -1;numerical
equality 5==5any variable
inequality 5!=4any variable
greater than, greather than or equal to$a>$b $a>=$bany variable
less than, less than or equal to$a<$b $a<=$bany variable
and ($a<1) and ($b>0)boolean
or($a<1) or ($b>0)boolean
not !$aboolean
concatenation$a="Break"."fast"string