Q: Can you populate variables given to a function the same way php exec does? When using php exec you can pass it with a variable not previously defined like this : 
exec('whoami', $result, $status);

and they will be populated with information afterwards or initialized in this function. Can you do something similar with a function inside a custom class?
I have tried to search for an answer but not sure on what to search for so i'm sorry if this has previously been mentioned here.

A: You to declare it as a reference:
function init(&$x) {
  $x = 0;
}
$a = 42;
init($a);
echo $a; // 0

This behavior is described in the PHP manual. It's the second paragraph of function arguments: Making arguments be passed by reference
