PHP Operators


PHP Tutorial > 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

Link to this page: If you find this page useful, we encourage you to link to this page. Simply copy and paste the code below to your website, blog, or profile.






Copyright 2007-2009  1keydata.com  All Rights Reserved.  Privacy Policy  



PHP Tutorial
PHP Variables
PHP Operators
PHP IF ELSE
PHP ELSEIF
PHP Switch
PHP While Loop
PHP FOR Loop
PHP DO WHILE Loop
PHP FOREACH Loop
PHP INCLUDE
PHP Functions
PHP ARRAY
PHP FORMS
PHP Cookies
PHP Redirect
PHP MySQL

PHP Commands

Resources