When calling a function with parameters, the variables in the parameters are copied/cloned in the function and use their new names. This way you can manipulate the input as you wish and leave the original variables untouched.
Another option is to pass the variables themselves (actual references) to the function, manipulate them and have the same values when leaving the function. This is done simply by adding “&” to the call:
1 2 3 4 5 6 7 8 9 10 |
<?php function moo(&$var) { $var++; } $a=5; moo($a); // $a is 6 here ?> |