php - Assigning and passing a reference variable in function -


function test(&$a) {     $a = $a + 3;  } 

if assign variable first , call it: $a = 3; test($a); echo $a; //it output 6

but if test($a = 3); echo $a; //it return 3

why that? doesnt' reference variable in second function call modify 6 well?

turn on strict standards see:

only variables should passed reference

you should not expect second example work @ all. fact seems coincidence, though php document it.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -