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['reference?'][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.4, 8.3.6
Fatal error: Uncaught InvalidArgumentException: Passed variable is not an array or object in /in/QhI4g:8 Stack trace: #0 [internal function]: ArrayObject->__unserialize(Array) #1 /in/QhI4g(8): unserialize('a:2:{s:11:"arra...') #2 {main} thrown in /in/QhI4g on line 8
Process exited with code 255.
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 Fatal error: Uncaught InvalidArgumentException: Passed variable is not an array or object in /in/QhI4g:8 Stack trace: #0 [internal function]: ArrayObject->__unserialize(Array) #1 /in/QhI4g(8): unserialize('a:2:{s:11:"arra...') #2 {main} thrown in /in/QhI4g on line 8
Process exited with code 255.
Output for 7.3.16 - 7.3.33
array(7) { [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(1) { [0]=> int(3) } } ["reference?"]=> NULL } [5]=> int(8) [6]=> array(2) { ["arrayobject"]=> object(ArrayObject)#3 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> int(3) } } ["reference?"]=> array(1) { [9]=> int(8) } } }
Output for 7.1.10 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.1
array(7) { [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(1) { [0]=> int(3) } } ["reference?"]=> array(1) { [0]=> int(3) } } [5]=> int(8) [6]=> array(2) { ["arrayobject"]=> object(ArrayObject)#3 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> int(3) } } ["reference?"]=> array(2) { [0]=> int(3) [9]=> int(8) } } }
Output for 5.4.2 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
array(7) { [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) [6]=> 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) } } }

preferences:
152.55 ms | 405 KiB | 240 Q