# PHP Operators

PHP has many types of operators for different purpose.Operators are used to perform some operations between variables

#### Arithmetic Operators

Arithmetic operators are those operators which are used to perform operations between generally numeric values.

OperatorDescription
+It is called Addition Operator it is used to add two or more variables. For eg. \$x+\$y.
-It is called Subtraction Operator it is used to get the difference of the two or more variables. For eg. \$x-\$y.
*It is called Multiplication Operator it is used to get the product of two or more variables. For eg. \$x*\$y.
/It is called Division Operator it is used to get the quotient of two or more variables. For eg. \$x/\$y.
%It is called Modulus Operator it is used to get the remainder of two or more variables. For eg. \$x%\$y.
\$x++It is called Post-Increment Operator it is used to return \$x then increase the variable value by 1
\$x--It is called Post-Decrement Operator it is used to return \$x then decrease the variable value by 1
++\$xIt is called Pre-Increment Operator it is used to increase the variable value by 1 then return \$x
--\$xIt is called Pre-Decrement Operator it is used to decrease the variable value by 1 then return \$x

#### Assignment Operators

Assignment operators are those operators which are used to set values to a variables.

OperatorDescription
\$x=\$yIt is used to to asign the values to the variable. For eg. \$x=100;
\$x+=\$yIt is same as \$x=\$x+\$y
\$x-=\$yIt is same as \$x=\$x-\$y
\$x*=\$yIt is same as \$x=\$x*\$y
\$x/=\$yIt is same as \$x=\$x/*\$y
\$x%=\$yIt is same as \$x=\$x%\$y

#### Comparison Operators

Cmparison operators are those operators which are used to compare two values.

OperatorDescription
\$x==\$yIt is called Equal Operator it returns true if \$x is equal to \$y
\$x===\$yIt is called Identical Operator it returns true if \$x is equal to \$y with same data type.
\$x!=\$yIt is called Not Equal Operator it returns true if \$x is not equal to \$y.
>It is called Greater Than Operator it returns true if \$x is greater than \$y.
<It is called Less Than Operator it returns true if \$x is less than \$y.
>=It is called Greater Than or Equal To Operator it returns true if \$x is greater than or equal to \$y.
<=It is called Less Than or Equal To Operator it returns true if \$x is less than or equal to \$y.

#### Logical Operators

Logical operators are those operators which are used to combine conditional statements.

OperatorDescription
\$x and \$yIt is same as \$x && \$y. It is called And Operator it returns true if \$x and \$y are true
\$x or \$yIt is same as \$x || \$y. It is called Or Operator it returns true if one of then is true.
\$x xor \$yIt is called Xor Equal Operator it returns true if only one of then is true,Not both.
!\$xIt is called Not Operator it returns true if \$x is not true.

#### Some More Operators

OperatorDescription
\$x . \$yIt is called Concatenation Operator it is used to concatenate two or more variables.
\$x .= \$yIt is called Concatenation Assignment Operator it is used to concatenate it appends the value of \$y to \$x.
❮ PrevNext ❯