3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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'])) { debug_zval_dump($o); 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');
based on Bartu
Output for 7.1.0
object(stdClass)#4 (0) refcount(2){ } Notice: A non well formed numeric value encountered in /in/v0Xvl on line 32 3 4 5 6 7 8 9 2 1 1
Output for 5.3.0 - 7.0.14
object(stdClass)#4 (0) refcount(2){ } 3 4 5 6 7 8 9 2 1 1
Output for 5.2.17
object(stdClass)#4 (0) refcount(2){ } 2547935070 4 3814547747 2949745219 362066431 2131035204 128752799 848637659 1141537418 1141537418
Output for 5.2.15 - 5.2.16
object(stdClass)#4 (0) refcount(2){ } 339838029 4 2509208438 3557032696 2017534531 1256171516 3385589220 3400198412 431845786 431845786
Output for 5.2.14
object(stdClass)#4 (0) refcount(2){ } 321800923 4 746296439 410153915 794258513 206625463 1261718954 2553909664 2692311505 2692311505
Output for 5.2.13
object(stdClass)#4 (0) refcount(2){ } 3221128602 4 4216488827 661859871 1568812085 4079298892 3398913975 929137490 381602778 381602778
Output for 5.2.12
object(stdClass)#4 (0) refcount(2){ } 1916440863 4 1548914530 3069212356 3147236740 2502418887 2575214838 3792364646 1384937175 1384937175
Output for 5.2.9, 5.2.11
object(stdClass)#4 (0) refcount(2){ } 3190999372 4 3753225249 2802118225 3573485929 2095645647 485842524 1441663217 3508469034 3508469034
Output for 5.2.10
object(stdClass)#4 (0) refcount(2){ } 1268489161 4 1381756351 1273689074 2154295599 4206973504 3505028368 1663187803 3724618520 3724618520
Output for 5.2.7 - 5.2.8
object(stdClass)#4 (0) refcount(2){ } 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/v0Xvl on line 20 object(stdClass)#4 (0) refcount(2){ } 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/v0Xvl on line 20 object(stdClass)#4 (0) refcount(2){ } 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/v0Xvl on line 20 Warning: Wrong parameter count for debug_backtrace() in /in/v0Xvl on line 20 Warning: Invalid argument supplied for foreach() in /in/v0Xvl 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/v0Xvl on line 20 Warning: Wrong parameter count for debug_backtrace() in /in/v0Xvl on line 20 Warning: Invalid argument supplied for foreach() in /in/v0Xvl 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/v0Xvl on line 20 Warning: Wrong parameter count for debug_backtrace() in /in/v0Xvl on line 20 Warning: Invalid argument supplied for foreach() in /in/v0Xvl 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/v0Xvl on line 20 Warning: Wrong parameter count for debug_backtrace() in /in/v0Xvl on line 20 Warning: Invalid argument supplied for foreach() in /in/v0Xvl 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/v0Xvl on line 20 Warning: Wrong parameter count for debug_backtrace() in /in/v0Xvl on line 20 Warning: Invalid argument supplied for foreach() in /in/v0Xvl on line 20 3623854121 0 2760637292 2048509259 1374088209 494384136 3613577688 18640134 972656262 972656262
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function spl_object_hash() in /in/v0Xvl 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/v0Xvl on line 17
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: spl_object_hash() in /in/v0Xvl 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/v0Xvl on line 17