3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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);
based on i3D7u
Output for 7.0.0 - 7.1.0
[3,2,1] [3,2,1]
Output for 5.4.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.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.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.