php - what is the value of $a and $b after the function call and why? (pass by reference and pass by value) -


what value of $a , $b after function call , why?

just clarify difference between pass reference , pass value

function dosomething( &$arg ) {     $return = $arg;     $arg += 1;     return $return; }  $a = 3; $b = dosomething( $a ); 

$a 4

$b 3

the former ($a) because $arg passed reference, latter ($b) because return value of function copy of (not reference to) initial value of argument.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

Error while updating a record in APEX screen -

c++ - In an add-in in Excel, written in C(++), how does one get the name of the function which called into the addin? -