Samiksha Jaiswal

Scope resolution operator

Updated on
Share on FacebookTweet on TwitterShare on LinkedIn

In computer programming, scope is an enclosing context where values and expressions are associated. The scope resolution operator helps to identify and specify the context to which an identifier refers, particularly by specifying a namespace. The specific uses vary across different programming languages with the notions of scoping. In many languages the scope resolution operator is written "::".


In some languages, notably those influenced by Modula-3, including Python and Go, modules are objects, and scope resolution within modules is a special case of usual object member access, so the usual method operator . is used for scope resolution. Other languages, notably C++ and Ruby, feature both scope resolution and method access, which interact in various ways; see examples below.


In PHP, the scope resolution operator is also called Paamayim Nekudotayim (Hebrew: פעמיים נקודתיים‎‎, pronounced [paʔaˈmajim nəkudaˈtajim]), which means “twice colon” in Hebrew.

The name "Paamayim Nekudotayim" was introduced in the Israeli-developed Zend Engine 0.5 used in PHP 3. Although it has been confusing to many developers who do not speak Hebrew, it is still being used in PHP 7, as in this sample error message:

A similar error can also occur where no scope resolution operator is present. For example, attempting to check whether a constant is empty() triggers this error:

As of PHP 5.4, error messages concerning the scope resolution operator still include this name, but have clarified its meaning somewhat:

There are other less obvious ways to trigger the error, for example by attempting to use the following invalid PHP expression:


In Ruby, scope resolution can be specified using namespaces (such as classes or modules).

Scope is also affected by sigils which preface variable names:

  • "$" - global variable
  • "@" - instance variable of self
  • "@@" - class variable
  • No sigil, lowercase or underscore - local variable or method
  • No sigil, uppercase - constant
  • References

    Scope resolution operator Wikipedia

    Similar Topics
    Lisa (1990 film)
    Nick Beighton
    Cayetano Corona Gaspariano