你可以像php exec一样填充给函数的变量吗?

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.

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