PHP Syntax Variables Assignemnt By Reference


- Info:

- Reference assignemnt means that target variable will point to source variable.

- Changes made to one variable will change the value of another because both variables point to the same memory

location which is being changed.


- Example:

- Create PHP Console Application Test.php.




$value1 = "Hello";

$value2 =& $value1; // $value1 and $value2 both equal "Hello"

$value2 = &$value1; // Alternative syntax

$value2 = "Goodbye"; // $value1 and $value2 both equal "Goodbye"