Scope Resolution Operator ::

The Scope Resolution Operator :: is a token that allows access to static, constant, and overridden properties or methods of a class.

Traditionally, this used to be a feature of the function get_class(). The operator is more modern and faster.

The double colon operator is used to access class related elements, such as

  • Static properties, X::$property

  • Static methods, X::method()

  • Static constants, X::CONSTANT

  • Class name, X::class

This operator is often called double-colon, or paamayim-nekudotayim: this means double-colon in Hebrew. It is said to be a lot easier to google than ::.

PHP also has a single colon operator :, used for goto labels, ternary operator, etc.

<?php

$a = new stdClass();

echo $a::class;

// identical to
echo get_class($a);

?>

Documentation

See also Scope Resolution operator in PHP and Scope Resolution operator (in PHP).

Related : Object Operator ->, Object Nullsafe Operator ?->, Static Method, Static Constant, Static Class, Static Property, Colon, Double, Null Safe Object Operator