Re: [PHP] Operator for functions

[email protected] (Aziz Saleh)
Newsgroups php.general
Message-ID <CAPJtNhX1QLnRbxsjbW53nDXHVcxwfPYvvmn6VsNO2p-wSWFcng@mail.gmail.com>
On Mon, Dec 19, 2016 at 3:22 PM, Sam Hobbs <[email protected]> wrote:

> What is the "->" operator for functions called?
>
> At the bottom of PHP: Operators - Manual <http://php.net/manual/en/lang
> uage.operators.php> (http://php.net/manual/en/language.operators.php) is
> the note:
>
> "The -> operator, not listed above, is called "object operator"
> (T_OBJECT_OPERATOR)."
>
> It has been down-voted 81 times. Is that because the operator is not
> called the "object operator"? Or is it because the note says that the
> operator is not listed?
>
> I apologize if my criticism is not appropriate, but the operator is not
> properly documented. The "->" operator should be listed among the other PHP
> operators and there should be documentation of it.
>
> The C++ standard calls the "." and "->" operators the "dot" and "arrow"
> operators, correspondingly. For example, see "5.2.4 Pseudo destructor call"
> in:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf
> That is the latest draft of the newest C++ standard.
>
> PHP can call its "->" operator whatever the designers decide, but there
> should be a definition to eliminate the confusion of different names
> depending on personal preference. A book I am reading calls the operator
> the "arrow operator". Is it called the object operator (as implied by the
> tag) or the arrow operator or something else?
>

There is a difference between a token and an operator, I think people
usually confuse the two. The -> is a parser token, indeed called the
T_OBJECT_OPERATOR (not sure why that comment was downvoted).

Here is a complete list of PHP's parser tokens:

http://php.net/manual/en/tokens.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.