PHP Operator1
PHP Operator1
1. Arithmetic operators
2. Assignment operators
3. Comparison operators
4. Increment/Decrement operators
5. Logical operators
6. String operators
7. Array operators
8. Conditional assignment operators
The PHP arithmetic operators are used with numeric values to perform
common arithmetical operations, such as addition, subtraction, multiplication
etc.
+ Addition $x + $y Sum of $x
and $y
* Multiplication $x * $y Product of
$x and $y
/ Division $x / $y Quotient Try it
of $x and »
$y
% Modulus $x % $y Remainder
of $x
divided by
$y
The PHP assignment operators are used with numeric values to write a value
to a variable.
The basic assignment operator in PHP is "=". It means that the left operand
gets set to the value of the assignment expression on the right.
x -= y x=x–y Subtraction
x /= y x=x/y Division
The PHP comparison operators are used to compare two values (number or
string):
|| Or $x || $y True if either $x
or $y is true
PHP has two operators that are specially designed for strings.
+ Union $x + $y Union of
$x and
$y
The PHP conditional assignment operators are used to set a value depending
on conditions: