Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: What does `array(&$this)` mean?

Tags:

php

this

In PHP, I would like to know what array(&$this) means.

like image 680
JeanDavidDaviet Avatar asked Apr 24 '12 08:04

JeanDavidDaviet


People also ask

What is array in PHP with example?

An array is a data structure that stores one or more similar type of values in a single value. For example if you want to store 100 numbers then instead of defining 100 variables its easy to define an array of 100 length.

What is the use of array?

In coding and programming, an array is a collection of items, or data, stored in contiguous memory locations, also known as database systems . The purpose of an array is to store multiple pieces of data of the same type together.

What is array data type in PHP?

In PHP, there are three types of arrays: Indexed arrays - Arrays with a numeric index. Associative arrays - Arrays with named keys. Multidimensional arrays - Arrays containing one or more arrays.

Is array an object in PHP?

An object is an instance of a class. It is simply a specimen of a class and has memory allocated. Array is the data structure that stores one or more similar type of values in a single name but associative array is different from a simple PHP array.


2 Answers

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.

like image 173
Jon Avatar answered Sep 29 '22 00:09

Jon


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.

like image 32
Anders Lindahl Avatar answered Sep 28 '22 23:09

Anders Lindahl