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

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -