Operators in PHP

In this tutorial we will lean Operators in PHP. Operators are special symbols which tells to PHP processor to do some special operations. For example There is + operator which tells PHP Processor to add two numbers (4+5). There are various operators in PHP and they are divided into some categories. List of Categories:

  • Arithmetic Operators
  • Comparison Operators
  • Assignment Operators
  • Inc/Dec Operators
  • Logical Operators
  • String Operators
  • Array Operators

Operators in PHP


Now we will learn about each category in detail. We will learn which operators are in each category and how do they work.

Arithmetic Operators: There are total five operators in this category. Arithmetic operators are used to perform some basic mathematical operations. Operators in this category are +,-, /, *, %. Check list of Arithmetic Operators.

OperatorNameDecsriptionExample
+AdditionAdd Two Number10+5
-SubractionSubtract second number from first umber10-5
*MultiplicationMultiply Two Number10*5
/DivisionDivision of Two Number10/5
%ModulusReturn Remainder after Devision10%5


Comparison Operators: Comparisons operators are use to compare two numbers. For example to check which number is greater from giver number(10>5). Result of comparison operators come in Boolean form mean 10>5 result of this would be true. List of operators in this category is as follow.

OperatorNameDecsriptionExample
==EqualReturn true if first value would equal to second10==10
===IdenticalReturn true if both operands would be of same data type10===10
!=Not equalReturn true if both values are not same10!=5
!==Not identicalReturn true if both values would not be of same type.10!===5
<Less thanReturn true if first value will be less than second10<20
>Greater thanReturn true if first value will greater than second10>5
<=Less than or equal toReturn true if first value will be less than or equal to second10<=5
>=Greater than or equal toReturn true if first value will be greater than or equals to second10>=5


Assignment Operators: Most common Assignment operator is =. Assignment operators are use to assign value to variables. There are total six assignment operators check this list.

OperatorNameDecsriptionExample
=Assignassign value to variables$num=10
+=Add and assignAssign value to variable after adding value on right hand side in previous value of variablenum+=10 ($num = $num+10)
-=Subtract and assignAssign value to variable after subtracting value on right hand side from previous value of variable$num-=10 ($num=$num-10)
*=Multiply and assignAssign value to variable after Multiply value on right hand side with previous value of variable$num*=10 ($num=$num*10)
/=Divide and assign quotientAssign value to variable after dividing previous value of variable with value on right hand$num/=10 ($num=$num/10)
%=Divide and assign modulusAssign remainder to variable after dividing previous value of variable with value on right hand$num%=10 ($num=$num%10)


Inc/Dec Operators:



Logical Operators:



String Operators:



Array Operators:





Share this tutorial with your friends on your social Media..

Operators in PHP Operators in PHP Operators in PHP Operators in PHP



Now You Can Follow All These Tutorials on Your Android Mobile Just Download This App.


Owlbuddy.com