3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = (object) array(); $b = (object) array(); function object_handle($obj) { static $mask = 0, $offset; if (!$mask) { if (defined('HHVM_VERSION')) { $offset = 24; } else { $offset = 8; } $o = (object) array(); $mask = hexdec(substr(spl_object_hash($o), $offset, 8)); // check if we are nested in an output buffering handler to prevent a fatal error with ob_start() below foreach (debug_backtrace(PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS : false) as $frame) { if (isset($frame['function'][0]) && !isset($frame['class']) && 'o' === $frame['function'][0] && in_array($frame['function'], array('ob_clean', 'ob_end_clean', 'ob_flush', 'ob_end_flush', 'ob_get_contents', 'ob_get_flush')) ) { $frame['line'] = 0; break; } } if (!empty($frame['line'])) { ob_start(); debug_zval_dump($o); $mask ^= substr(ob_get_clean(), 17); } } return hexdec(substr(spl_object_hash($obj), $offset, 8)) ^ $mask; } //ob_start('abc'); //ob_end_flush(); $o = array(); echo object_handle($o[]=(object) array()), "\n"; echo object_handle($o[]=(object) array()), "\n"; echo object_handle($o[]=(object) array()), "\n"; echo object_handle($o[]=(object) array()), "\n"; echo object_handle($o[]=(object) array()), "\n"; echo object_handle($o[]=(object) array()), "\n"; echo object_handle($o[]=(object) array()), "\n"; echo object_handle($b), "\n"; echo object_handle($a), "\n"; function abc() { global $a; isset($a) or $a = (object) array(); return object_handle($a); } ob_start('abc');
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: A non-numeric value encountered in /in/Bartu on line 31 3 Warning: A non-numeric value encountered in /in/Bartu on line 31 4 Warning: A non-numeric value encountered in /in/Bartu on line 31 5 Warning: A non-numeric value encountered in /in/Bartu on line 31 6 Warning: A non-numeric value encountered in /in/Bartu on line 31 7 Warning: A non-numeric value encountered in /in/Bartu on line 31 8 Warning: A non-numeric value encountered in /in/Bartu on line 31 9 Warning: A non-numeric value encountered in /in/Bartu on line 31 2 Warning: A non-numeric value encountered in /in/Bartu on line 31 1 7
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: A non-numeric value encountered in /in/Bartu on line 31 3 Warning: A non-numeric value encountered in /in/Bartu on line 31 4 Warning: A non-numeric value encountered in /in/Bartu on line 31 5 Warning: A non-numeric value encountered in /in/Bartu on line 31 6 Warning: A non-numeric value encountered in /in/Bartu on line 31 7 Warning: A non-numeric value encountered in /in/Bartu on line 31 8 Warning: A non-numeric value encountered in /in/Bartu on line 31 9 Warning: A non-numeric value encountered in /in/Bartu on line 31 2 Warning: A non-numeric value encountered in /in/Bartu on line 31 1 7
Output for 8.0.0 - 8.0.30
Warning: A non-numeric value encountered in /in/Bartu on line 31 3 4 5 6 7 8 9 2 1 10
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: A non well formed numeric value encountered in /in/Bartu on line 31 3 4 5 6 7 8 9 2 1 10
Output for 7.3.32 - 7.3.33
3 4 5 6 7 8 9 2 1 10
Output for 7.1.0 - 7.1.33
Notice: A non well formed numeric value encountered in /in/Bartu on line 31 3 4 5 6 7 8 9 2 1 1
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20
3 4 5 6 7 8 9 2 1 1
Output for 5.2.17
2547935070 4 3814547747 2949745219 362066431 2131035204 128752799 848637659 1141537418 1141537418
Output for 5.2.15 - 5.2.16
339838029 4 2509208438 3557032696 2017534531 1256171516 3385589220 3400198412 431845786 431845786
Output for 5.2.14
321800923 4 746296439 410153915 794258513 206625463 1261718954 2553909664 2692311505 2692311505
Output for 5.2.13
3221128602 4 4216488827 661859871 1568812085 4079298892 3398913975 929137490 381602778 381602778
Output for 5.2.12
1916440863 4 1548914530 3069212356 3147236740 2502418887 2575214838 3792364646 1384937175 1384937175
Output for 5.2.9, 5.2.11
3190999372 4 3753225249 2802118225 3573485929 2095645647 485842524 1441663217 3508469034 3508469034
Output for 5.2.10
1268489161 4 1381756351 1273689074 2154295599 4206973504 3505028368 1663187803 3724618520 3724618520
Output for 5.2.7 - 5.2.8
743472053 4 3111768615 3873806680 1003831645 478254684 4204994978 6757251 2647410167 2647410167
Output for 5.2.6
Notice: Use of undefined constant PHP_VERSION_ID - assumed 'PHP_VERSION_ID' in /in/Bartu on line 20 4023139345 4 341408247 949201916 2711476305 1609088342 4135671693 1898100807 2306014241 2306014241
Output for 5.2.5
Notice: Use of undefined constant PHP_VERSION_ID - assumed 'PHP_VERSION_ID' in /in/Bartu on line 20 3174279611 4 3140447067 1007821509 1726814073 869439616 1693474599 314050330 1672017471 1672017471
Output for 5.2.4
Notice: Use of undefined constant PHP_VERSION_ID - assumed 'PHP_VERSION_ID' in /in/Bartu on line 20 Warning: Wrong parameter count for debug_backtrace() in /in/Bartu on line 20 Warning: Invalid argument supplied for foreach() in /in/Bartu on line 20 1218706527 0 1636124447 1833807604 1283473960 3360760785 948672449 3857447919 590748615 590748615
Output for 5.2.3
Notice: Use of undefined constant PHP_VERSION_ID - assumed 'PHP_VERSION_ID' in /in/Bartu on line 20 Warning: Wrong parameter count for debug_backtrace() in /in/Bartu on line 20 Warning: Invalid argument supplied for foreach() in /in/Bartu on line 20 100970335 0 2516611248 64172235 3121338140 1153677688 660160136 2851235370 593372901 593372901
Output for 5.2.2
Notice: Use of undefined constant PHP_VERSION_ID - assumed 'PHP_VERSION_ID' in /in/Bartu on line 20 Warning: Wrong parameter count for debug_backtrace() in /in/Bartu on line 20 Warning: Invalid argument supplied for foreach() in /in/Bartu on line 20 2786353270 0 2811335873 3686491042 199915373 1153024475 1436768303 3444593828 3231219048 3231219048
Output for 5.2.1
Notice: Use of undefined constant PHP_VERSION_ID - assumed 'PHP_VERSION_ID' in /in/Bartu on line 20 Warning: Wrong parameter count for debug_backtrace() in /in/Bartu on line 20 Warning: Invalid argument supplied for foreach() in /in/Bartu on line 20 2154961812 0 4015313381 3874874234 3987421029 1915234544 3978071073 647959012 1577327704 1577327704
Output for 5.2.0
Notice: Use of undefined constant PHP_VERSION_ID - assumed 'PHP_VERSION_ID' in /in/Bartu on line 20 Warning: Wrong parameter count for debug_backtrace() in /in/Bartu on line 20 Warning: Invalid argument supplied for foreach() in /in/Bartu on line 20 3623854121 0 2760637292 2048509259 1374088209 494384136 3613577688 18640134 972656262 972656262
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Call to undefined function spl_object_hash() in /in/Bartu on line 17
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: spl_object_hash() in /in/Bartu on line 17
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: spl_object_hash() in /in/Bartu on line 17
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: spl_object_hash() in /in/Bartu on line 17

preferences:
264.83 ms | 401 KiB | 355 Q