Select Chapter ❯
PHP Tutorial
- PHP Introduction
- PHP Variables
- PHP Operators
- PHP Loops
- PHP Decision
- PHP Arrays
- PHP Functions
- PHP Forms
- PHP Include
- PHP File I/O
PHP Advanced
PHP Extra
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.
Operator | Description |
---|---|
+ | 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 |
++$x | It is called Pre-Increment Operator it is used to increase the variable value by 1 then return $x |
--$x | It 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.
Operator | Description |
---|---|
$x=$y | It is used to to asign the values to the variable. For eg. $x=100; |
$x+=$y | It is same as $x=$x+$y |
$x-=$y | It is same as $x=$x-$y |
$x*=$y | It is same as $x=$x*$y |
$x/=$y | It is same as $x=$x/*$y |
$x%=$y | It is same as $x=$x%$y |
Comparison Operators
Cmparison operators are those operators which are used to compare two values.
Operator | Description |
---|---|
$x==$y | It is called Equal Operator it returns true if $x is equal to $y |
$x===$y | It is called Identical Operator it returns true if $x is equal to $y with same data type. |
$x!=$y | It 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.
Operator | Description |
---|---|
$x and $y | It is same as $x && $y. It is called And Operator it returns true if $x and $y are true |
$x or $y | It is same as $x || $y. It is called Or Operator it returns true if one of then is true. |
$x xor $y | It is called Xor Equal Operator it returns true if only one of then is true,Not both. |
!$x | It is called Not Operator it returns true if $x is not true. |
Some More Operators
Operator | Description |
---|---|
$x . $y | It is called Concatenation Operator it is used to concatenate two or more variables. |
$x .= $y | It is called Concatenation Assignment Operator it is used to concatenate it appends the value of $y to $x. |