---
title: "1-2-3 PHP operators"
url: https://www.exakat.io/1-2-3-php-operators/
date: 2025-05-17
modified: 2025-05-17
author: "dams"
description: "[caption id=\"attachment_15799\" align=\"alignleft\" width=\"300\"] 1-2-3 operators in PHP[/caption] 1-2-3 PHP operators I learnt my PHP on a European keyboard, and it was always a pain to use some strange symbols...."
categories:
  - "Technology"
tags:
  - "fun"
  - "operators"
image: https://www.exakat.io/wp-content/uploads/2025/05/123.320.jpg
word_count: 848
---

# 1-2-3 PHP operators

[![1-2-3 operators in PHP](https://www.exakat.io/wp-content/uploads/2025/05/123.320-300x300.jpg)](https://www.exakat.io/wp-content/uploads/2025/05/123.320.jpg)1-2-3 operators in PHP

# 1-2-3 PHP operators

I learnt my PHP on a European keyboard, and it was always a pain to use some strange symbols. When I moved to Canada, I quickly realized that the chosen symbols were actually very easily accessible on the keyboard: it was just my layout that was less practical.

Then, I also realized how these symbols are repeatedly used to make larger ones. There is the single `=` for assignation, then the double `==` for equality and then the triple `===` for identity. It is probably easier to repeat an existing symbol, than to summon a new one, which might be cumbersome to reach on the keyboard.

There is a bit of laziness in this pattern. `==` might easily mistaken with `===` (and vice versa) and the mistake might be begnin (or not), but mistaking `=`and `==` is, most of the time, a bug.

Here is as selection of 1-2-3 PHP operators, along with their documentation.

| 1 | 2 | 3 |
| --- | --- | --- |
| . | .. | ... |
| + | ++ | +++ |
| - | -- | --- |
| * | ** | *** |
| / | // | /// |
| > | >> | >>> |
| < | << | <<< |
| = | == | === |
| @ | @@ | @@@ |
| ? | ?? | ??? |
| : | :: | ::: |
| ! | !! | !!! |
| $ | $$ | $$$ |

## Dots in PHP

- `.` is the operator of [string concatenation](https://www.php.net/manual/en/language.operators.string.php).
- `..` is a syntax error. It is not supported in PHP. In other language, it denotes a range between two operators.
- `...` is the [ellipsis operator](https://www.php.net/manual/en/language.types.array.php), to spread or collect values out or in an array

## Plus in PHP

- `+` is the [addition operator](https://www.php.net/manual/en/language.operators.arithmetic.php), for numbers and arrays.
- `++` is the [increment operator](https://www.php.net/manual/en/language.operators.increment.php). It comes in two flavors, pre-increment or post increment.
- `+++` is a syntax oddity, where there is no space between an incremented variable and its addition with another value: `$b = $a+++ 1;` is `$b = $a++ + 1;`

## Minus in PHP

- `-` is the [substraction operator](https://www.php.net/manual/en/language.operators.arithmetic.php), for numbers only.
- `--` is the [decrement operator](https://www.php.net/manual/en/language.operators.increment.php). It comes in two flavors, pre-increment or post increment.
- `---` is a syntax oddity, where there is no space between a decremented variable and its substraction with another value: `$b = $a--- 1;` is `$b = $a-- - 1;`

## Star in PHP

- `*` is the [multiplication operator](https://www.php.net/manual/en/language.operators.arithmetic.php), for numbers.
- `**` is the [power operator](https://www.php.net/manual/en/language.operators.arithmetic.php). It is the multiplication of multiplications, basically.
- `***` is not supported. Math has a notion of towers of powers, where `4 *** 4` would be `4 ** (4 ** 4)`. That number is already beyond the integer range, so the operator is probably unuseful.

## Slash in PHP

- `/` is the [decimal division operator](https://www.php.net/manual/en/language.operators.arithmetic.php), for numbers.
- `//` is a [one line comment](https://www.php.net/manual/en/language.basic-syntax.comments.php).
- `///` is a one line comment, starting with a slash.

## Greater than in PHP

- `>` is the [greater than comparison operator](https://www.php.net/manual/en/language.operators.comparison.php).
- `>>` is the [right bitshift operator](https://www.php.net/manual/en/language.operators.bitwise.php), which moves bits to the right.
- `>>>` is not supported.

## Lesser than in PHP

- `<` is the [lesser than comparison operator](https://www.php.net/manual/en/language.operators.comparison.php).
- `<<` is the [left bitshift operator](https://www.php.net/manual/en/language.operators.bitwise.php), which moves bits to the left.
- `<<<` is the start of the Heredoc and Nowdoc sequence.

## Equal in PHP

- `=` is the assignation operator, which gives a value to a variable.
- `==` is the [comparison operator](https://www.php.net/manual/en/language.operators.comparison.php). Types are adapted before the comparison actually happens.
- `===` is the [identity operator](https://www.php.net/manual/en/language.operators.comparison.php), which compares values and their types.

## Question in PHP

- `?` is half the [ternary operator](https://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary), along with the colon.
- `??` is the [null coalesce](https://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.coalesce) operator. It is a ternary operator, specialized with null values.
- `???` is a [classic comment](https://github.com/search?q=%3F%3F%3F+language%3APHP+&type=code) in the code, when someone was surprised by some code.

## Colon @ in PHP

- `:` is the label operator, `label:`, that works with [goto](https://www.php.net/manual/en/control-structures.goto.php). It is also the other half of the [ternary operator](https://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary).
- `::` is the [scope resolution operator](https://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php), which reachs data at the class level, and not at the object level.
- `:::` is not supported.

## Exclamation ! in PHP

- `!` is the [negation operator](https://www.php.net/manual/en/language.operators.logical.php): it turns any value into its boolean opposite.
- `!!` is the [negation negation operator](https://www.php.net/manual/en/language.operators.logical.php). It is basically a shorter `(boolean)` cast operator, and a barbarism coming from other languages.
- `!!!` is the [negation operator](https://www.php.net/manual/en/language.operators.logical.php), but three times longer to write.

## Arobase @ in PHP

- `@` is the [noscream operator](https://www.php.net/manual/en/language.operators.errorcontrol.php), which mutes error reporting on a syntax.
- `@@` is the [noscream operator](https://www.php.net/manual/en/language.operators.errorcontrol.php), which mutes error reporting on a error-muted expression. It is in case the code should really not emit errors.
- `@@@` is the [noscream operator](https://www.php.net/manual/en/language.operators.errorcontrol.php), which mutes error reporting on a doubly error-muted expression. It is in case the code should really really, and I mean really, not emit errors.

# 1-2-3 operators are fun!

It is interesting to discover the different meanings of an symbol as it is repeated. It might vary a lot in meaning and usage.

It is also interesting to realise that some of these repeated symbol operators are not used yet, and might be promoted to an actual PHP features. Replacing `range(1, 19)` by `1..19` would be a nice new feature for PHP 8.5.

We could also dream of `:::`, `|||`, `___` or even quadruples operators `....` or `@@@@`. Well, sometimes, we already have them!