<?php
function g($a, $b, $c) {
f($a, $b, $c);
}
function f(int $a, int $b = null, int $c = null) {
//xdebug_debug_zval('a', 'b', 'c');
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");
//error_log($str);
preg_match('/^Argument (\\d+) /', $str, $m);
$i = $m[1]-1;
$a = "$i";
$bt = debug_backtrace(null, 2);
$bt1 = $bt[1]['args'];
//xdebug_debug_zval("bt1");
//print_r($bt);
$a = "$a {$bt[1]['args'][$i]}";
$bt[1]['args'][$i] = add1($bt[1]['args'][$i]);
$bt1 = $bt[1]['args'];
//xdebug_debug_zval("bt1");
$a = "$a {$bt[1]['args'][$i]}";
if (false && $i == 1) {
$a = "$a ({$bt[1]['args'][1+$i]}";
++$bt[1]['args'][1+$i];
$a = "$a {$bt[1]['args'][1+$i]})";
}
error_log($a);
//$zval = $bt[1]['args'][1];
//$bt[1]['args'][1] = add1($bt[1]['args'][1]);
//print_r($bt);
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.33, 7.2.0 - 7.2.33, 7.3.0 - 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.38, 5.6.0 - 5.6.24
- 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/i3D7u on line 9
Process exited with code 255. - Output for 5.0.0 - 5.0.5
- Parse error: parse error, unexpected '[', expecting ')' in /in/i3D7u on line 9
Process exited with code 255. - Output for 4.4.2 - 4.4.9
- Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/i3D7u 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/i3D7u on line 7
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error, expecting `')'' in /in/i3D7u on line 7
Process exited with code 255.
preferences:
263.95 ms | 401 KiB | 376 Q