PHP function reference problem

<?php
$var3 = 1;
$var4 = 2;
function test2(){
    global $var3,$var4;
    $var4 = &$var3;
    $var4 = 3;
    //$var3 = 3;
}
test2();
echo $var4 ;
?>

question 1: why does $var4 still output 2 here? it doesn"t work to re-assign values to $var3 or $var4 later. My understanding is that $var3 passes references and values to $var4, in the function, so $vars4 should point to the same address as $var3.

question 2: please recommend a book suitable for PHPer. I prefer to focus on the above books on the principles of PHP. Thank you.

Php
Dec.15,2021

consult comments directly

  

when you define a global variable in a function, you pass a reference, and
defines global $var4 . The relationship between the two variables is $local_var4 = & $global_var4;
. The third line in the function can be understood as: $local_var4 = & $local_var3 , and then becomes a reference to $local_var3 ,
and $local_var3 is also $global_var3 .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35894-e4ef.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35894-e4ef.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?