PHP Operators ,Operands & Expression
PHP Operators , Operands and Expression are sets of characters which perform a special task in the PHP code.
For example : An assignment operator the equals sign ( =
) is use to assign a value to a variable.which is known as assignment operator.
We use a plus sign ( +
) to add two number together and it is known as an arithmetic operator.
Operands:
Operator can’t do any things without operand and operand is that on which an operator work. For example: 5 + 3 = 8 Here, 5 and 3 are operand & plus sign(+) , equal sign(=) are operators and 5+3=8 is an expression .
Dear learner in this tutorial i discussed details about PHP Operators, operand and Expression . I Hope everybody must be benefited form this tutorial.
Various Types of PHP operators:
1. Arithmetic Operators:
List of Arithmetic operators in PHP:
Operator with expression

Name

Description

Example

Result

a+ b

Addition

Sum of a and b 
5+3

8

ab

Subtraction

Difference of a & b 
64

2

a*b

Multiplication

Product of a and b 
8*8

64

a/b

Division

Quotient of a and b 
25/5

5

a%b

Modules/mod

Remainder of a divided by b 
7%3

1

a

Negation

Opposite of a 
5

5

x . y

Concatenation

Concatenate of two string 
“Hell” . “World “

Helloworld

2. Decrementing/Incrementing Operators in PHP:
Operator with expression

Name

Description

++a

Preincrement

Increment a by one, then returns a.

a++

Postincrement

Return a, then increment a by one

–a

Predecrement

Decrements a by one, then return a.

a–

postdecrement

Return a then decrements a by one.

3. Assignment Operators:
An assignment operator the equals sign ( =
) is use to assign a value to a variable.which is known as assignment operator.
For example:
Assignment Operators with expression

Description

a=a

Here left operand get the value of the expression on the right side

a+=b Or a=a+b

Addition

a=b Or a=ab

Subtraction

a*=b Or a=a*b

Multiplication

a /=b Or a= a /b

Division

a%=b Or a= a%b

Modulus/mod

x.=y Or a=a .b

Concatenate two strings

4. Logical Operators in PHP:
List of logical Operators in PHP:
Operator

Name

Description

Example

a and b

And

True if both a and b are true. 
a=5,b=2 (a<8 and b>1 ) then return true. 
a or b

Or

True if one or both a & b are true 
a=7,b=9 if (a==7 or b==6) then return true. 
a xor b

Xor

True if one Or a or b is true but not both. 
a=3,b=5 If(a==3 xor b=5) return false.Because both are true. 
a && b

Logical And

True if both a and b are true. 
a=8,b=4 if (a<9 && B>3) then return true. 
a  b

Logical Or

True if one or both a & b are true. 
a=2,b=9 if( a==2  b==9) then return true 
! a

Not

True if a is not true 
a=10,b=12 if !(a==b) then return true. 
5. Comparison Operators in PHP
Comparison operators help you to compare between two values:
List of Comparison Operators in PHP:
Operator with expression

Name

Description

a = = a

Equal

True if a is equal to b

a = = = a

Identical

True if a is equal to b and they are same in type

a < > b

Not equal

True if a is not equal to b

a > b

Greater than

True if a is greater than b

a < b

Less than

True if a is less than b

a!=b

Not equal

True if a is not equal to b

a!== b

Not identical

True if a is not equal to b or they are not same in type

a <= b

Less than or equal to

True if a is less than or equal to b

a >= b

Grater than or equal to

True if a is greater than or equal to b
