## PHP Operators

### The Arithmatic Operators:

Example | Name | Result |
---|---|---|

$n + $z | Addition | Sum of $n and $z. |

$n – $z | Subtraction | Difference of $n and $z. |

$n * $z | Multiplication | Product of $n and $z. |

$n / $z | Division | Quotient of $n and $z. |

$n % $z | Modulus | Remainder of $n divided by $z. |

$n ** $z | Exponentiation | Result of raising $n to the $z power. Introduced in PHP 5.6. |

### The Assignment Operators:

Assignment | Same as | Result |
---|---|---|

$n = $z | $n = $z | n get the value of z. |

$n += $z | $n = $n + $z | Addition |

$n -= $z | $n = $n – $z | Subtraction |

$n *= $z | $n = $n * $z | Multiplication |

$n /= $z | $n = $n / $z | Division |

$n %= $z | $n = $n % $z | Modulus |

### Comparison Operators:

Example | Name | Result |
---|---|---|

$n == $z | Equal | Returns true if $n is equal to $z |

$n === $z | Identical | Returns true if $n is equal to $z, and they are of the same type. |

$n != $z | Not equal | Returns true if $n is not equal to $z |

$n <> $z | Not equal | Returns true if $n is not equal to $z |

$n !== $z | Not identical | Returns true if $n is not equal to $z |

$n < $z | Less than | Returns true if $n is less than $z |

$n > $z | Greater than | Returns true if $n is greater than $z |

$n <= $z | Less than or equal to | Returns true if $n is less than or equal to $z. |

$n => $z | Greater than or equal to | Returns true if $n is greater than or equal to $z. |

### Increment/decrement Operators:

Example | Name | Result |
---|---|---|

++$i | Pre-increment | Increments $i by one, then returns $i |

$i++ | Post-increment | Returns $i, then increments $i by one |

–$i | Pre-decrement | Decrements $i by one, then returns $i |

$i– | Post-decrement | Returns $i, then decrements $i by one |

### Logical Operators:

Example | Name | Result |
---|---|---|

$i and $j | And | Returns true if both $i and $j are true. |

$i or $j | Or | Returns true if either $i or $j is true. |

$i xor $j | Xor | Returns true if either $i or $j is true, but not both. |

! $i | Not | Returns true if $i is not true. |

$i && $j | And | Return true if both $i and $j are true. |

$i || $j | Or | Returns true if either $i or $j is true. |

### String Operators:

Example | Name | Result |
---|---|---|

$a . $b | Concatenation | Concatenation of $a and $b |

$a .= $b | Concatenation assignment | Appends $a to $b |

### Array Operators:

Example | Name | Result |
---|---|---|

$i + $j | Union | Union of $i and $j. |

$i == $j | Equality | Returns true if $i and $j have the same key/value pairs. |

$i === $j | Identity | Returns true if $i and $j have the same key/value pairs in the sameorder and of the same types. |

$i != $j | Inequality | Returns true if $i is not equal to $j. |

$i <> $j | Inequality | Returns true if $i is not equal to $j. |

$i !== $j | Non-identity | Returns true if $i is not identical to $j. |