Reputation: 299
In PHP, I would like to know what array(&$this)
means.
Upvotes: 10
Views: 13002
Reputation: 1425
This is creating an array with a single element. The element is a reference to the object from which it is executed it. For more information see the documentation on passing by reference.
Upvotes: 0
Reputation: 437474
It's a construct that initializes an array which contains one element: a reference to the object the array is initialized in. Inside every class, you can refer to the "current" instance using $this
.
Upvotes: 13
Reputation: 42890
Its PHPs pass by reference construction. Typically this means that a reference to the parameter is passed to the function instead of a copy of the value, so that modifications inside the function affect the object.
Upvotes: 6