Tutorial :PHP function declaration: function example(&$Test) { } Explain &?



Question:

In this example, what does the & accomplish?


Solution:1

The ampersand means the function gets a reference to the variable. The php manual can explain it better than i can!

http://php.net/manual/en/language.references.php


Solution:2

It makes the parameter pass by reference, instead of pass by value.

From php5 and above, it is not necessary to pass objects by reference anymore.


Solution:3

& indicates that the variable is accessed by reference rather than by value. See the PHP documentation on references for further information.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »