What is the name of the = operator in PHP used in arrays?

14

In PHP, when we are going to declare a array directly, we have the => operator.

I know that in PHP we have -> , which is object separator , but I needed to give the name to => and could not explain.

What's his name?

    
asked by anonymous 28.07.2015 / 17:26

2 answers

11
The double arrow ( => ) according to the manual is used to assign a value to a specific key in the array definition and also to separate a key from a value in a foreach, as quoted by bigown .

  

For arrays, assigning a value to a named key is performed using the "= >" operator . The precedence of this operator is the same as the other assignment operators.

Source: Assignment Operators

On the precedence page you can see this line, note the last element of the second column.

Associativity |Operators                                       |Additional Information
right         |  = += -= *= **= /= .= %= &= |= ^= <<= >>= =>   |assignment

As for the name of the symbol => in the PHP documentation there seems to be no specific name, the closest to the formal would be T_DOUBLE_ARROW (as pointed out in the comments), which appears in syntax errors.

Informally it is known as fat comma , term that probably came from Perl language PHP inherited some features .

    
28.07.2015 / 17:29
9

Not an operator, contrary to popular belief and error in Wikipedia, at least for PHP. The language has these operators . It's just a language-building element that separates the key from associative arrays .

    
28.07.2015 / 17:31