PHP Operators
PHP Operators
Operators
• An operator is a special symbol that
performs a specific operation on operands
and then returns a result.
• Types of operators in PHP:
• Arithmetic operators
• Relational and equality operators
• Logical operators
• Assignment operator
• concatenation operator
© K.S. Mbise Operators Slide 2
Arithmetic operators
• PHP supports various arithmetic
operators for all integer and floating
point numbers.
• Arithmetic operators are used with
numeric values to perform common
arithmetical operations, such as
addition, subtraction, multiplication,
etc.
© K.S. Mbise Operators Slide 3
Arithmetic operators cont…
Operator Use Description
+ $op1 + $op2 Adds $op1 and $op2
+= $op1+=$op2 $op1=$op1+$op2
-= $op1-=$op2 $op1=$op1-$op2
*= $op1*=$op2 $op1=$op1*$op2
/= $op1/=$op2 $op1=$op1/$op2
%= $op1%=$op2 $op1=$op1%$op2