Operators in PHP

Before we get into learning about operators in PHP, we must first know what in general do we mean by an expression, operand and an operator. Below is the diagram that speaks out exactly what we need to know.

Operators in PHP

Going ahead, there are a total of 7 operators in PHP, namely –


1. Arithmetic operators – For operations like $a+b, $a-$b, etc.

2. Comparison operators – For operations like $a<$b, $c>5, etc.

3. Increment/Decrement operators – For operations like $a++, $b++, ++$c, etc.

4. Logical operators – For operations like ($a or $b), ($a || $b), ($a && $b), etc.

5. String operators – For operations like $a.$b for string concatenation, considering both $a and $b are some valid strings.

6. Assignment operators – For operations like $x = $y, $x = $x + $y, $x += $y, etc.

7. Array operators – We will learn about Arrays in PHP soon. However, considering $a and $b to be two different arrays, $a+$b would produce the union of two arrays, $a==$b would check if the two arrays have the same key value pairs, $a===$b would check the order of the key value pairs along with their values and so on.

Receive our updates to your inbox

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.