11

Possible Duplicates:
In, PHP, what is the “->” operator called and how do you say it when reading code out loud?

I use it all the time, it's impossible to search for. What is the technical name for it?

like $object->property

UPDATE: I see now that someone asked this question before, but when you search for something like "php ->" you don't get good results.

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
pfunc
  • 1,305
  • 2
  • 24
  • 52
  • Is it not a pointer, as used in C since an array is a list of references to actual objects. – Adam Holmes Jan 31 '11 at 22:06
  • Possible duplicate of http://stackoverflow.com/questions/1580757/what-is-the-official-name-of-cs-arrow-operator – Damp Jan 31 '11 at 22:08
  • 6
    [Reference - What does this symbol mean in PHP?](http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php) – mario Jan 31 '11 at 22:10
  • @mario that is a nice reference. – pfunc Jan 31 '11 at 23:44
  • @pfunc: I've just stolen that link. It's one of the links in the [|faq|](http://stackoverflow.com/questions/tagged/php?sort=faq&pagesize=50) tab for the `php` questions. – mario Jan 31 '11 at 23:48

4 Answers4

19

Simply enough, it's called the arrow operator

ETA:

As others have mentioned, the documentation also calls this token the "object operator". So, the docs aren't entirely self consistent, which I suppose is true of any real world documentation.

dtbarne
  • 8,110
  • 5
  • 43
  • 49
Eric Petroelje
  • 59,820
  • 9
  • 127
  • 177
  • +1 for referencing its mention in documentation – Wiseguy Jan 31 '11 at 22:09
  • that linked to "Static Keyword" not arrow operator – pfunc Jan 31 '11 at 22:12
  • And btw the `class::method` operator is called the Scope Resolution Operator http://de.php.net/manual/en/language.oop5.paamayim-nekudotayim.php – Marc Jan 31 '11 at 22:12
  • 1
    @pfunc - yes, but if you look at the 4th sentence on the page, you'll see it mention how "Static properties cannot be accessed through the object using the arrow operator ->" – Eric Petroelje Jan 31 '11 at 22:13
  • 2
    Actually, it's called the [`Object Operator`](http://ch2.php.net/manual/en/tokens.php) as defined in the token list (`T_OBJECT_OPERATOR`)... – ircmaxell Jan 31 '11 at 22:15
  • @ircmaxell - So the `::` would be called the `PAAMAYIM NEKUDOTAYIM` then as well? :) – Eric Petroelje Jan 31 '11 at 22:17
  • 1
    The definition is the same for C++. Leave it to standards committees and documentation writers to make an official name that tells you absolutely nothing about how it's used. If you don't know it through some other means, you won't get any hints from the name. :) http://stackoverflow.com/questions/1580757/what-is-the-official-name-of-cs-arrow-operator/1580778#1580778 – John Jan 31 '11 at 22:17
  • @Eric: Yes. I'm not arguing if we should be using the token names or not, but I was just pointing out the alternative name as defined by PHP itself (not the documentation). – ircmaxell Jan 31 '11 at 22:19
  • I agree with ircmaxell, this is normally referred to as the object operator. The arrow operator is more appropriate as a short form of the double arrow operator (the one used for hash declarations and foreach loops with key). – NikiC Jan 31 '11 at 22:21
  • @ircmaxell - agreed, just giving you a hard time. The documentation isn't entirely consistent on this one (as tends to be true of all real world documentation). – Eric Petroelje Jan 31 '11 at 22:23
  • @marc - it's call the scope resolution operator because nobody can pronounce PAAMAYIM NEKUDOTAYIM ;) – HorusKol Jan 31 '11 at 22:32
  • +1 to @John: Knowing that it is called the 'arrow operator' doesn't help with knowing what it's function is within PHP. – HorusKol Jan 31 '11 at 22:33
  • -1 for snatching unrighteous rep. all reputation gained from duplicated question should be nulled. – Your Common Sense Jan 31 '11 at 22:48
8

It's also known as T_OBJECT_OPERATOR in the tokenizer/parser http://de3.php.net/manual/en/tokens.php

mario
  • 144,265
  • 20
  • 237
  • 291
5

The member access operator. Sometimes called the single arrow operator or the dereference operator.

Phssthpok
  • 1,629
  • 1
  • 14
  • 21
1

This is called "dereference" in most languages, I suspect its the same thing in PHP.

NikiC
  • 100,734
  • 37
  • 191
  • 225
EToreo
  • 2,936
  • 4
  • 30
  • 36
  • 3
    I think you me "dereference"? It's not really the same thing as the traditional dereference operator in languages with explicit pointers (such as C's `*`). – Amber Jan 31 '11 at 22:09
  • I completely agree with you, Amber. – EToreo Jan 31 '11 at 22:43