3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump([ $original_set = [ 'arrayobject' => new arrayobject( [3] ), 'reference?' => [5] ], $original_serialized = serialize( $original_set ), $original_unserialized = unserialize( $original_serialized ), $withreference_serialized = preg_replace( '/a:1:{i:0;i:5;}}/', 'R:4;}', $original_serialized ), $withreference_unserialized = unserialize( $withreference_serialized ), $withreference_unserialized['arrayobject'][9] = 8, # $withreference_unserialized, # $withreference_unserialized['arrayobject'][9] === $withreference_unserialized['reference?'][9] # ? 'looks like a reference' : 'does not look like a reference' , ]) ;
Output for 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.6
Fatal error: Uncaught InvalidArgumentException: Passed variable is not an array or object in /in/LJ9il:8 Stack trace: #0 [internal function]: ArrayObject->__unserialize(Array) #1 /in/LJ9il(8): unserialize('a:2:{s:11:"arra...') #2 {main} thrown in /in/LJ9il on line 8
Process exited with code 255.
Output for 7.3.2 - 7.3.33
array(6) { [0]=> array(2) { ["arrayobject"]=> object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> int(3) } } ["reference?"]=> array(1) { [0]=> int(5) } } [1]=> string(110) "a:2:{s:11:"arrayobject";C:11:"ArrayObject":29:{x:i:0;a:1:{i:0;i:3;};m:a:0:{}}s:10:"reference?";a:1:{i:0;i:5;}}" [2]=> array(2) { ["arrayobject"]=> object(ArrayObject)#2 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> int(3) } } ["reference?"]=> array(1) { [0]=> int(5) } } [3]=> string(100) "a:2:{s:11:"arrayobject";C:11:"ArrayObject":29:{x:i:0;a:1:{i:0;i:3;};m:a:0:{}}s:10:"reference?";R:4;}" [4]=> array(2) { ["arrayobject"]=> object(ArrayObject)#3 (1) { ["storage":"ArrayObject":private]=> array(2) { [0]=> int(3) [9]=> int(8) } } ["reference?"]=> NULL } [5]=> int(8) }
Output for 7.0.23 - 7.0.33, 7.1.9 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.1
array(6) { [0]=> array(2) { ["arrayobject"]=> object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> int(3) } } ["reference?"]=> array(1) { [0]=> int(5) } } [1]=> string(110) "a:2:{s:11:"arrayobject";C:11:"ArrayObject":29:{x:i:0;a:1:{i:0;i:3;};m:a:0:{}}s:10:"reference?";a:1:{i:0;i:5;}}" [2]=> array(2) { ["arrayobject"]=> object(ArrayObject)#2 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> int(3) } } ["reference?"]=> array(1) { [0]=> int(5) } } [3]=> string(100) "a:2:{s:11:"arrayobject";C:11:"ArrayObject":29:{x:i:0;a:1:{i:0;i:3;};m:a:0:{}}s:10:"reference?";R:4;}" [4]=> array(2) { ["arrayobject"]=> object(ArrayObject)#3 (1) { ["storage":"ArrayObject":private]=> array(2) { [0]=> int(3) [9]=> int(8) } } ["reference?"]=> array(2) { [0]=> int(3) [9]=> int(8) } } [5]=> int(8) }
Output for 7.0.0 - 7.0.22, 7.1.0 - 7.1.8

Process exited with code 139.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
array(6) { [0]=> array(2) { ["arrayobject"]=> object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> int(3) } } ["reference?"]=> array(1) { [0]=> int(5) } } [1]=> string(110) "a:2:{s:11:"arrayobject";C:11:"ArrayObject":29:{x:i:0;a:1:{i:0;i:3;};m:a:0:{}}s:10:"reference?";a:1:{i:0;i:5;}}" [2]=> array(2) { ["arrayobject"]=> object(ArrayObject)#2 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> int(3) } } ["reference?"]=> array(1) { [0]=> int(5) } } [3]=> string(100) "a:2:{s:11:"arrayobject";C:11:"ArrayObject":29:{x:i:0;a:1:{i:0;i:3;};m:a:0:{}}s:10:"reference?";R:4;}" [4]=> array(2) { ["arrayobject"]=> object(ArrayObject)#3 (1) { ["storage":"ArrayObject":private]=> &array(2) { [0]=> int(3) [9]=> int(8) } } ["reference?"]=> &array(2) { [0]=> int(3) [9]=> int(8) } } [5]=> int(8) }

preferences:
232.1 ms | 404 KiB | 373 Q