What is this Operator?

Hello, Sorry not finding the answer in Google.

What is the operator called ?

$conn -> close();

This one

->

That’s a good question - I’ve never actually seen it referred to by name before. A bit of googling revealed this page: http://www.robert-gonzalez.com/2009/03/04/php-operators-double-and-single-arrow/ which attempts to answer your question.

So it seems to be most commonly called the ‘object operator’.

Edit: See also http://stackoverflow.com/questions/2588149/what-is-the-php-operator-called-and-how-do-you-say-it-when-reading-code-out

3 Likes

ohh thank you so much. the arrow operator or the object operator… kool

In C++ the “->” operator is called “member of pointer” but the PHP “->” operator is actually closer to the “.” operator in C++ and that is called “member of object”. So although PHP does not call the “->” operator “member of object” it might help to think of it that way too.

I sure can’t find the “->” operator defined anywhere in the PHP documentation, only examples of its use. A proper language would have a proper definition.

As it does.

http://php.net/manual/en/language.oop5.properties.php

Within class methods non-static properties may be accessed by using → (Object Operator): $this->property (where property is the name of the property). Static properties are accessed by using the :: (Double Colon): self::$property.

1 Like

That page is about “properties”. The “->” operator should be defined among the other PHP Operators or at least in a page such as PHP: Scope Resolution Operator (::slight_smile: - Manual. The informal definition of the “->” operator as in the “properties” page is an indication of the informal nature of PHP.

If you want good examples of precise documentation, look at documentation of instructions (assembly language) for processors such as Intel and IBM processors. They are the most precise I have seen that define what happens for each instruction.

When you go to a language reference such as this C++ Language Reference then you can quickly get to a list of all C++ operators that includes the Member Access Operators: . and → . If the PHP documentation where to do something similar then it would be easy to find the documentation of “->” but as it is now it is not easy to find the documentation and hence this question.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.