3v4l.org

run code in 300+ PHP versions simultaneously
<?php class child implements Serializable { public function serialize() { return null; } public function unserialize($serialized) { } } class test { private $elems = []; public function add($something) { $this->elems[] = $something; } } $child = new child(); $t = new test(); $t->add(1); $t->add('test'); var_dump(unserialize(serialize($t))); $t->add($child); var_dump(unserialize(serialize($t))); $t->add($child); var_dump(unserialize(serialize($t)));
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: child implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /in/cTPe9 on line 3 object(test)#3 (1) { ["elems":"test":private]=> array(2) { [0]=> int(1) [1]=> string(4) "test" } } object(test)#3 (1) { ["elems":"test":private]=> array(3) { [0]=> int(1) [1]=> string(4) "test" [2]=> NULL } } object(test)#3 (1) { ["elems":"test":private]=> array(4) { [0]=> int(1) [1]=> string(4) "test" [2]=> NULL [3]=> NULL } }
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 Deprecated: child implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /in/cTPe9 on line 3 object(test)#3 (1) { ["elems":"test":private]=> array(2) { [0]=> int(1) [1]=> string(4) "test" } } object(test)#3 (1) { ["elems":"test":private]=> array(3) { [0]=> int(1) [1]=> string(4) "test" [2]=> NULL } } object(test)#3 (1) { ["elems":"test":private]=> array(4) { [0]=> int(1) [1]=> string(4) "test" [2]=> NULL [3]=> NULL } }
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.4 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
object(test)#3 (1) { ["elems":"test":private]=> array(2) { [0]=> int(1) [1]=> string(4) "test" } } object(test)#3 (1) { ["elems":"test":private]=> array(3) { [0]=> int(1) [1]=> string(4) "test" [2]=> NULL } } object(test)#3 (1) { ["elems":"test":private]=> array(4) { [0]=> int(1) [1]=> string(4) "test" [2]=> NULL [3]=> NULL } }
Output for 7.3.0 - 7.3.3
object(test)#3 (1) { ["elems":"test":private]=> array(2) { [0]=> int(1) [1]=> string(4) "test" } } object(test)#3 (1) { ["elems":"test":private]=> array(3) { [0]=> int(1) [1]=> string(4) "test" [2]=> NULL } } Notice: unserialize(): Error at offset 75 of 77 bytes in /in/cTPe9 on line 32 bool(false)

preferences:
181.24 ms | 402 KiB | 225 Q