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

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.

Operator | Name | Decsription | Example |
---|---|---|---|

+ | Addition | Add Two Number | 10+5 |

- | Subraction | Subtract second number from first umber | 10-5 |

* | Multiplication | Multiply Two Number | 10*5 |

/ | Division | Division of Two Number | 10/5 |

% | Modulus | Return Remainder after Devision | 10%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.

Operator | Name | Decsription | Example |
---|---|---|---|

== | Equal | Return true if first value would equal to second | 10==10 |

=== | Identical | Return true if both operands would be of same data type | 10===10 |

!= | Not equal | Return true if both values are not same | 10!=5 |

!== | Not identical | Return true if both values would not be of same type. | 10!===5 |

< | Less than | Return true if first value will be less than second | 10<20 |

> | Greater than | Return true if first value will greater than second | 10>5 |

<= | Less than or equal to | Return true if first value will be less than or equal to second | 10<=5 |

>= | Greater than or equal to | Return true if first value will be greater than or equals to second | 10>=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.

Operator | Name | Decsription | Example |
---|---|---|---|

= | Assign | assign value to variables | $num=10 |

+= | Add and assign | Assign value to variable after adding value on right hand side in previous value of variable | num+=10 ($num = $num+10) |

-= | Subtract and assign | Assign value to variable after subtracting value on right hand side from previous value of variable | $num-=10 ($num=$num-10) |

*= | Multiply and assign | Assign value to variable after Multiply value on right hand side with previous value of variable | $num*=10 ($num=$num*10) |

/= | Divide and assign quotient | Assign value to variable after dividing previous value of variable with value on right hand | $num/=10 ($num=$num/10) |

%= | Divide and assign modulus | Assign 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:

Logical Operators:

String Operators:

Array Operators: