Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does :: mean in php? [duplicate]

Tags:

php

Possible Duplicate:
what is the “::” notation in php used for?

I noticed this code while modifying a friends code and noticed this piece of code: TestPages::LoadMenu();

what does :: mean in php?

A great answer would mean a lot.

Thanks!

like image 528
PinoyStackOverflower Avatar asked Aug 05 '11 14:08

PinoyStackOverflower


People also ask

What is :: mean in PHP?

In PHP, the double colon :: is defined as Scope Resolution Operator. It used when when we want to access constants, properties and methods defined at class level. When referring to these items outside class definition, name of class is used along with scope resolution operator.

What does this -> do in PHP?

What is -> in PHP? This is referred to as the object operator, or sometimes the single arrow operator. It is an access operator used for access/call methods and properties in a PHP object in Object-Oriented Programming (OOP).

What is cloning in PHP?

The clone keyword is used to create a copy of an object. If any of the properties was a reference to another variable or object, then only the reference is copied. Objects are always passed by reference, so if the original object has another object in its properties, the copy will point to the same object.

What does double question mark mean PHP?

In PHP 7, the double question mark(??) operator known as Null Coalescing Operator. It returns its first operand if it exists and is not NULL; otherwise, it returns its second operand. It evaluates from left to right. Null Coalescing operator also can be used in a chain format.


2 Answers

It's the 'Scope Resolution Operator'.

The Scope Resolution Operator (also called Paamayim Nekudotayim) or in simpler terms, the double colon, is a token that allows access to static, constant, and overridden properties or methods of a class.

http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php

like image 82
Dogbert Avatar answered Oct 06 '22 00:10

Dogbert


In layman terms it is used to call static Methods of a Class.

In your example, LoadMenu() is a static function of the TestPages class.

This means that you do not have to create an instance of a TestPages to call LoadMenu()

like image 43
jondavidjohn Avatar answered Oct 05 '22 23:10

jondavidjohn