3v4l.org

run code in 300+ PHP versions simultaneously
<?php class c { public $prop; function __wakeup() { $this->prop = 'awake'; } } $c = new c; $c->prop = new stdclass; $a = [$c]; $a[] =& $c->prop; $s = serialize($a); var_dump($s); var_dump($a); $a2 = unserialize($s); var_dump($a2); $a2[0] = 'ref?'; var_dump($a2);
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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
string(60) "a:2:{i:0;O:1:"c":1:{s:4:"prop";O:8:"stdClass":0:{}}i:1;R:3;}" array(2) { [0]=> object(c)#1 (1) { ["prop"]=> &object(stdClass)#2 (0) { } } [1]=> &object(stdClass)#2 (0) { } } array(2) { [0]=> object(c)#3 (1) { ["prop"]=> &string(5) "awake" } [1]=> &string(5) "awake" } array(2) { [0]=> string(4) "ref?" [1]=> string(5) "awake" }
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 string(60) "a:2:{i:0;O:1:"c":1:{s:4:"prop";O:8:"stdClass":0:{}}i:1;R:3;}" array(2) { [0]=> object(c)#1 (1) { ["prop"]=> &object(stdClass)#2 (0) { } } [1]=> &object(stdClass)#2 (0) { } } array(2) { [0]=> object(c)#3 (1) { ["prop"]=> &string(5) "awake" } [1]=> &string(5) "awake" } array(2) { [0]=> string(4) "ref?" [1]=> string(5) "awake" }
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
string(60) "a:2:{i:0;O:1:"c":1:{s:4:"prop";O:8:"stdClass":0:{}}i:1;R:3;}" array(2) { [0]=> object(c)#1 (1) { ["prop"]=> &object(stdClass)#2 (0) { } } [1]=> &object(stdClass)#2 (0) { } } array(2) { [0]=> object(c)#3 (1) { ["prop"]=> string(5) "awake" } [1]=> object(stdClass)#4 (0) { } } array(2) { [0]=> string(4) "ref?" [1]=> object(stdClass)#4 (0) { } }

preferences:
158.09 ms | 402 KiB | 228 Q