Reason of ampersand (&) sign before a variable name in PHP

<?php
    $number = 1;
    $pointer = &$number;
   
    echo $number."<br/>"; // outputs 1
    echo $pointer."<br/>"; // outputs 1
   
    $pointer = 2;
   
    echo $number."<br/>"; // outputs 2
    echo $pointer."<br/>"; // outputs 2
?>

Comments

Popular posts from this blog

Timus 1209. 1, 10, 100, 1000... accepted solution in C

Timus Problem 1086. Cryptography Accepted Solution in C

Timus 1083. Factorials!!! Accepted Solution in C