3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class logger { function __construct() { print "logger constructing\n"; } function __wakeup() { print "logger wakeup\n"; } function __destruct() { print "logger destruct\n"; } } class obj { var $prop; function __wakeup() { $this->prop = 'awake'; } } $a = []; $a[] = new stdclass; $a[0]->one = new logger; $a[] = new obj; $a[1]->prop =& $a[0]; $a[] =& $a[0]->one; var_dump(serialize($a)); $x = 'a:3:{i:0;O:8:"stdClass":1:{i:0;O:6:"logger":0:{}}i:1;O:3:"obj":1:{s:4:"prop";R:2;}i:2;R:3}'; var_dump($x); $y = unserialize($x); var_dump($y);
based on tSqer
Output for 7.1.5 - 7.2.0
logger constructing string(97) "a:3:{i:0;O:8:"stdClass":1:{s:3:"one";O:6:"logger":0:{}}i:1;O:3:"obj":1:{s:4:"prop";R:2;}i:2;R:3;}" string(90) "a:3:{i:0;O:8:"stdClass":1:{i:0;O:6:"logger":0:{}}i:1;O:3:"obj":1:{s:4:"prop";R:2;}i:2;R:3}" Notice: unserialize(): Error at offset 86 of 90 bytes in /in/5EFbO on line 30 logger wakeup logger destruct bool(false) logger destruct
Output for 7.1.0
logger constructing string(97) "a:3:{i:0;O:8:"stdClass":1:{s:3:"one";O:6:"logger":0:{}}i:1;O:3:"obj":1:{s:4:"prop";R:2;}i:2;R:3;}" string(90) "a:3:{i:0;O:8:"stdClass":1:{i:0;O:6:"logger":0:{}}i:1;O:3:"obj":1:{s:4:"prop";R:2;}i:2;R:3}" logger wakeup Notice: unserialize(): Error at offset 86 of 90 bytes in /in/5EFbO on line 30 logger destruct bool(false) logger destruct
Output for 5.4.12 - 7.0.20
logger constructing string(97) "a:3:{i:0;O:8:"stdClass":1:{s:3:"one";O:6:"logger":0:{}}i:1;O:3:"obj":1:{s:4:"prop";R:2;}i:2;R:3;}" string(90) "a:3:{i:0;O:8:"stdClass":1:{i:0;O:6:"logger":0:{}}i:1;O:3:"obj":1:{s:4:"prop";R:2;}i:2;R:3}" logger wakeup logger destruct Notice: unserialize(): Error at offset 86 of 90 bytes in /in/5EFbO on line 30 bool(false) logger destruct
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/5EFbO on line 21
Process exited with code 255.