3v4l.org

run code in 300+ PHP versions simultaneously
<?php function g($a, $b, $c) { f($a, $b, $c); } function f(int $a, int $b = null, int $c = null) { error_log(json_encode([$a, $b, $c])); error_log(json_encode(func_get_args())); } function add1($x) { return ++$x; } function changeF($code, $str) { error_log("in changeF"); preg_match('/^Argument (\\d+) /', $str, $m); $i = $m[1]-1; $a = "$i"; $bt = debug_backtrace(null, 2); $bt1 = $bt[1]['args']; $a = "$a {$bt[1]['args'][$i]}"; $bt[1]['args'][$i] = add1($bt[1]['args'][$i]); $bt1 = $bt[1]['args']; $a = "$a {$bt[1]['args'][$i]}"; error_log($a); return true; } set_error_handler('changeF', E_ALL); //f(2, 1); g(3, 2, 1);

preferences:
34.77 ms | 402 KiB | 5 Q