- PHP Operator is used to performing operations on operands. operators are used to performing operations on variables or values.
- PHP Operators can be divides in the following categories:

**Assignment operators****Arithmetic operators****Comparison operators****Logical operators****Increment/Decrement operators****String operators****Array operators**

- This operator is used with numeric values to write a value to a variable.
- The basic assignment operator in PHP is "=".

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

= | Assign | $ab = $cd |

+= | Add and assignment operator | $ab += $cd |

-= | Subtract and assignment operator | $ab -= $cd |

*= | Multiply and assignment operator | $ab *= $cd |

/= | Divide and assignment operator | $ab /= $cd |

%= | Modulus and assignment operator | $ab %= $cd |

- Arithmetic Operators are used to performing common arithmetic operations like addition, subtraction, with numeric values.

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

+ | Addition | $ab + $cd |

- | Subtraction | $ab - $cd |

* | Multiplication | $ab * $cd |

/ | Division | $ab / $cd |

% | Modulus | $ab % $cd |

** | Exponentiation | $ab ** $cd |

- This operator is comparing two values, such as number or string.

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

== | Equal | $ab == $cd |

=== | Identical | $ab === $cd |

!= | Not equal | $ab != $cd |

<> | Not equal | $ab <> $cd |

!== | Not identical | $ab !== $cd |

> | Greater than | $ab > $cd |

< | Less than | $ab < $cd |

>= | Greater than or equal to | $ab >= $cd |

<= | Less than or equal to | $ab <=$ cd |

<=> | Spaceship | $ab <==> $cd |

- This operator is comparing two values, such as number or string.

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

and | and | $ab and $cd |

or | or | $ab or $cd |

xor | xor | $ab xor $cd |

&& | and | $ab && $cd |

|| | or/td> | $ab || $cd |

! | not | !$ab |

- The PHP increment operators are used to increment a variable's value and decrement operators are used to decrement a variable's value.

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

++ | Increment | ++$ab |

$ab++ | ||

-- | decrement | --$ab |

$ab-- |

- String operators are specially used for strings.

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

. | Concatenation | $ab . $cd |

.= | Concatenation assignment | $ab .= $cd |

- Array operators are used to compare arrays.

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

+ | Union | $a + $y |

== | Equality | $a == $b |

!= | Inequality | $a != $b |

=== | Identity | $a === $b |

!== | Non-Identity | $a !== $b |

<> | Inequality | $a <> $b |

Copyright ©

Made in India,

Happy coding. Stay safe and stay healthy