Paamayim Nekudotayim Operator

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).


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



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


Functionality of PHP trim() function


trim — Strip whitespace (or other characters) from the beginning and end of a string.



string trim ( string $str [, string $charlist ] )



The string that will be trimmed.

Optionally, the stripped characters can also be specified using the charlist parameter.


Argument Options:

PHP trim function returns a string with white space stripped from the beginning and end of str. Without the second parameter, trim() will strip these characters:


” ” (ASCII 32 (0x20)), an ordinary space
“\0” (ASCII 0 (0x00)), the NUL-byte
“\n” (ASCII 10 (0x0A)), a new line (line feed)
“\t” (ASCII 9 (0x09)), a tab
“\r” (ASCII 13 (0x0D)), a carriage return
“\x0B” (ASCII 11 (0x0B)), a vertical tab


Can I trim other characters than these?

Yes, this is possible and easy, you just use a second parameter with all characters you want to trim.


Trim these characters from the beginning and end of a string: “S”,”c”,”e”.

<pre>$mystr = trim ( "Scriparticle" , "Sce") ;
echo $mystr;

Result will


PHP Operator Precedence and Associativity

PHP as usual all languages has a set of rules (known as Operator Precedence) that decide how complicated expressions are processed.


$myVar = 2 * 10 – 1;

Should $myVar be 19 or 18?


If you cannot decide why there are two possibilities, break them up using parentheses like this


$myVar = (2 * 10) – 1
$myVar = 2 * (10 – 1);


In the first example, 2 is multiplied by 10, then 1 is subtracted from the result, but in the second one, 1 has subtracted from 10 and multiplied by 2 makes it 18.If there is ambiguity in your expressions, PHP will resolve them according to its internal set of rules called as Operator Precedence.


The precedence of an operator is important to bind two expressions together. In the expression 2 + 5 * 3, the answer is 17 and not 21 because the “*” operator has a higher precedence than the “+” operator.


If operator precedence is equal, left to right associativity is used.

The following table lists the precedence of operators with the highest-precedence operators listed at the top.


Associativity Operators Additional Information
non-associative clone new clone and new
left [ array()
non-associative ++ — increment/decrement
non-associative ~ – (int) (float) (string) (array) (object) (bool) @ types
non-associative instanceof types
right ! Logical
left * / % arithmetic
left + – . arithmetic and string
left << >> bitwise
non-associative < <= > >= <> comparison
non-associative == != === !== comparison
left & bitwise and references
left bitwise
left | bitwise
left && logical
left || logical
left ? : ternary
right = += -= *= /= .= %= &= |= = <<= >>= assignment
left and logical
left xor logical
left or logical
left , many uses