Re: [PHP] Operator for functions
- Date: Mon, 19 Dec 2016 16:08:23 -0500
- From: Aziz Saleh <azizsaleh@xxxxxxxxx>
- Subject: Re: [PHP] Operator for functions
On Mon, Dec 19, 2016 at 3:22 PM, Sam Hobbs <Sam@xxxxxxxxxxxxxxxxxx> 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"
> 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"
> 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: