So I stumbled upon something I didn't realise: call_user_func_array
apparently interrupts the code, but doesn't get back to finishing the rest of it! In other words, it works as if to return
, break
or exit
the current function it was called from, ignoring all code that follows.
class B {
function bar($arg1, $arg2) {
$result = "$arg1 and $arg2";
echo "Indeed we see '$result'.<br>\n";
return $result;
}
}
class A {
function foo() {
$args = ['apples', 'oranges'];
echo "This line executes.<br>\n"
$result = call_user_func_array(['B', 'bar'], $args);
echo "This line never executes.<br>\n";
echo "Thus we won't be able to use the phrase '$result' within this function.<br>\n";
}
}
How can we return to and finish the rest of foo
?