HomeCoding & Programming

Paamayim Nekudotayim Operator

Paamayim Nekudotayim Operator
Like Tweet Pin it Share Share Email

In PHP, the scope resolution operator is also called Paamayim Nekudotayim (Hebrew Language), which means “twice colon” or “double dot twice”.

 

As you might know PHP 3.0 was created by the Zend team, and it was powered by the Zend Engine 0.5.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 don’t speak Hebrew Language, it is still being used in PHP 5.

 

Paamayim Nekudotayim or Scope Resolution Operator (::)

 

It is a token that allows access to static, constant, and overridden properties or methods of a class.

When referencing these items from outside the class definition, use the name of the class.

As of PHP 5.3.0, it’s possible to reference the class using a variable. The variable’s value can not be a keyword (e.g. self, parent and static).

<?php

class OtherClass extends MyClass
{
public static $my_static = 'static variable';
public static function doubleColon() {
echo parent::CONST_VALUE;
echo self::$my_static;
}
}

$classname = 'OtherClass';
echo $classname::doubleColon(); // As of PHP 5.3.0
OtherClass::doubleColon();

?>

 

Three special keywords self, parent and static are used to access properties or methods from inside the class definition.

 

Comments (1)

Comments are closed.