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);
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
[3,2,1] [3,2,1]
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.28
in changeF 0 3 4 in changeF 1 2 3 in changeF 2 1 2 [4,2,1] [4,3,2]
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/Eh7AA on line 8
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[', expecting ')' in /in/Eh7AA on line 8
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/Eh7AA on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting ')' in /in/Eh7AA on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/Eh7AA on line 7
Process exited with code 255.

preferences:
254.1 ms | 401 KiB | 346 Q