PHP Operators

SQL     Data Warehousing     CSS     PHP     HTML     Database Normalization


PHP Tutorial > PHP Commands > Operators

The most common PHP operators are assignment operators, arithmetic operators, combined operators, comparison operators, and logical operators. Each type is discussed separately below.

Assignment Operators

The basic assignment operator in PHP is "=". This means that the operand to the left of "=" gets set to the value to the right of "=".

Arithmetic Operators

OperatorExampleResult
+4 + 26
-4 - 22
*4 * 28
/4 / 22
%4 % 20
++x = 4; x++;x = 5
--x = 4; x--;x = 3

Combined Operators

You can combine an arithmetic operator with the assignment operator to form a combined operator. Combined operators are shown below:

OperatorExampleMeaning
+=y += xy = y + x
-=y -= xy = y - x
*=y *= xy = y * x
/=y /= xy = y / x
%=y %= xy = y % x

Comparison Operators

OperatorMeaning
==is equal to
!=is not equal to
>is greater than
>=is greater than or equal to
<is less than
<=is less than or equal to

Logical Operators

OperatorMeaning
||or
&&and
andand
oror
xorxor
!not

Next: PHP IF ELSE



Copyright © 2014   1keydata.com  All Rights Reserved.  Privacy Policy   About   Contact