Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the "->" PHP operator called? [closed]

People also ask

What is -> called 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). Example.

What does -> mean in code?

The -> is called the arrow operator. It is formed by using the minus sign followed by a greater than sign. Simply saying: To access members of a structure, use the dot operator. To access members of a structure through a pointer, use the arrow operator.

What is the use of => in PHP?

Answer: In PHP => is known as a double arrow operator or used as an associative array. This array is used to provide name keys. That means the named key will have an only value which you'll assign that associative array.

What is the --> operator in C C ++?

It is used with a pointer variable pointing to a structure or union. The arrow operator is formed by using a minus sign, followed by the greater than symbol as shown below. Operation: The -> operator in C or C++ gives the value held by variable_name to structure or union variable pointer_name.


The official name is "object operator" - T_OBJECT_OPERATOR.


I call it "dart"; as in $Foo->bar() : "Foo dart bar"

Since many languages use "dot" as in Foo.bar(); I wanted a one-syllable word to use. "Arrow" is just too long-winded! ;)

Since PHP uses . "dot" for concatenation (why?) I can't safely say "dot" -- it could confuse.

Discussing with a co-worker a while back, we decided on "dart" as a word similar enough to "dot" to flow comfortably, but distinct enough (at least when we say it) to not be mistaken for a concatenating "dot".


When reading PHP code aloud, I don't pronounce the "->" operator. For $db->prepare($query); I mostly say "Db [short pause] prepare query." So I guess I speak it like a comma in a regular sentence.

The same goes for the Paamayim Nekudotayim ("::").


When reading the code to myself, I think of it like a "possessive thing".

For example:

x->value = y->value

would read "x's value equals y's value"