Php operators Logical Conditional Ternary

Php operators Logical – Conditional – Ternary

 The most common PHP operators are
  • assignment operators
  • arithmetic operators
  • combined operators
  • comparison operators
  • logical operators.

Each type is discussed separately below.
Assignment Php 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 "=". 

Syntax:-

Pho Operators Example Result
+ 4 + 2 6
4 – 2 2
* 4 * 2 8
/ 4 / 2 2
% 4 % 2 0
++ x = 4; x++; x = 5
x = 4; x–; x = 3

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

Operator Example Meaning
+= y += x y = y + x
-= y -= x y = y – x
*= y *= x y = y * x
/= y /= x y = y / x
%= y %= x y = y % x

Comparison Php Operators
Syntax:-

Operator Meaning
== 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 Php Operators
Syntax:-

Operator Meaning
|| or
&& and
and and
or or
xor xor
! not
xvideos

Admin has written 171 articles