➤ In PHP, References enable accessing the same variable content by different names.
A reference variable is created by prefixing & (ampersand) sign to original variable.
For instance:
$x = 10;
$y = 20;
$y = &$x;
echo " x = $x \n"; // outputs: x = 10
echo " y = $y \n\n"; // outputs: y = 10
$y = 20;
echo " x = $x \n"; // outputs: x = 20
echo " y = $y \n"; // outputs: y = 20
by Levani Makhareishvili
2 years ago
PHP
References
1
Pro tip: use ```triple backticks around text``` to write in code fences