Mega Code Archive

 
Categories / Php / Functions
 

Making arguments be passed by reference

<? function add_some_extra(&$string) {     $string .= 'and something extra.'; } $str = 'This is a string, '; add_some_extra($str); echo $str;  function foo ($bar) { $bar .= ' and something extra.'; } $str = 'This is a string, '; foo ($str); echo $str;  foo (&$str); echo $str;  ?>