Static members

A static member belongs to the class and not to an instance: you access it with ::, without an object. self:: refers to the current class and static:: to the called class (late static binding). Overusing static state makes code hard to test.

Example

class Compteur {
  public static int $total = 0;
}
Compteur::$total++;

Related concepts

The whole glossary