ScoRpion
ScoRpion

Reputation: 11474

What is the name of the :: operator?

I am new to PHP, and I am practicing with some online tutorials. I usually encounter the sign :: while going through books, online tutorial or blogs. Even if I check some PHP demo applications I see this operator. I tried to put this sign in Google, but I got unexpected results. I even tried to search it in other forums as well, but I didn't got the right answer. I usually call it a bubble colon, but what is its technical name?

Upvotes: 1

Views: 1918

Answers (4)

usoban
usoban

Reputation: 5478

It's called scope resolution operator. More information in Scope Resolution Operator (::) (PHP manual).

Upvotes: 3

phihag
phihag

Reputation: 287865

:: is the scope resolution operator (you may sometimes find references to Paamayim Nekudotayim, hebrew for "double colon"). It is used to call static functions of a class, as in

class MyClass {
  public static function hi() {
    echo "hello, world";
  }
}
MyClass::hi();

For more details on classes and objects, refer to the official documentation.

Upvotes: 6

CodeCaster
CodeCaster

Reputation: 151594

A single one is called a colon, so you could search for "php double colon" and would find this:

http://php.net/manual/en/keyword.paamayim-nekudotayim.php

Scope Resolution Operator (::)

Sometimes it is useful to refer to functions and variables in base classes or to refer to functions in classes that have not yet any instances. The :: operator is being used for this.

Upvotes: 1

Patrick Glandien
Patrick Glandien

Reputation: 7851

It has the exotic name "Paamayim Nekudotayim", but you may just call it Scope Resolution Operator.

Upvotes: 3

Related Questions