Passing Argument by Refrence
Home Courses Community Support
Passing Argument by Refrence

Ampersand (&) in PHP is used to allow two variable to refer the same content. If we use $x = &$y, it means $x will point to $y's content but it is not $y.

By using Passing by reference two variable can point to the same content.

Let's see below example-

$X = 5;
$Y = &$X; // $Y references the same value as $X, currently 1
$Y = $Y + 4; // 5 is added to $Y, which effects $X the same way
echo "Y is equal to $Y and X is equal to $X.";


Y is equal to 9 and X is equal to 9.



← Preview

Function with Argument

Next →

Value Return using Function


Our mission is to provide highly effective and quality education via innovative solutions. Geeksdemy look forward to bridge the gap between in-demand technology and academics in order to deliver innovative, easy, interesting and affordable learning across the Globe.


  • Python
  • Game Development with Unity 3D
  • Arduino
  • PCB & Circuit Designing
  • Robotics and Embedded C
  • 8051/8052 Embedded Systems
  • QuadCopter & UAV
  • MATLAB with Robotics
  • Raspberry Pi
Learn On the Go!
Get the Android App
Get the iOS App