3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo1 { public $a; public function __construct($a) { $this->a = $a; }} class foo2 { protected $a; public function __construct($a) { $this->a = $a; }} class foo3 { private $a; public function __construct($a) { $this->a = $a; }} $foo1 = new foo1("test"); $foo2 = new foo2("test"); $foo3 = new foo3("test"); var_dump(serialize($foo1)); var_dump(serialize($foo2)); var_dump(serialize($foo3)); var_dump(unserialize('O:4:"foo1":1:{s:1:"a";s:4:"test";}')); var_dump(unserialize('O:4:"foo2":1:{s:1:"a";s:4:"test";}')); var_dump(unserialize('O:4:"foo3":1:{s:1:"a";s:4:"test";}'));
Output for 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(34) "O:4:"foo1":1:{s:1:"a";s:4:"test";}" string(37) "O:4:"foo2":1:{s:4:"*a";s:4:"test";}" string(40) "O:4:"foo3":1:{s:7:"foo3a";s:4:"test";}" object(foo1)#4 (1) { ["a"]=> string(4) "test" } object(foo2)#4 (1) { ["a":protected]=> string(4) "test" } object(foo3)#4 (1) { ["a":"foo3":private]=> string(4) "test" }
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(34) "O:4:"foo1":1:{s:1:"a";s:4:"test";}" string(37) "O:4:"foo2":1:{s:4:"*a";s:4:"test";}" string(40) "O:4:"foo3":1:{s:7:"foo3a";s:4:"test";}" object(foo1)#4 (1) { ["a"]=> string(4) "test" } object(foo2)#4 (1) { ["a":protected]=> string(4) "test" } object(foo3)#4 (1) { ["a":"foo3":private]=> string(4) "test" }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25
string(34) "O:4:"foo1":1:{s:1:"a";s:4:"test";}" string(37) "O:4:"foo2":1:{s:4:"*a";s:4:"test";}" string(40) "O:4:"foo3":1:{s:7:"foo3a";s:4:"test";}" object(foo1)#4 (1) { ["a"]=> string(4) "test" } object(foo2)#4 (2) { ["a":protected]=> NULL ["a"]=> string(4) "test" } object(foo3)#4 (2) { ["a":"foo3":private]=> NULL ["a"]=> string(4) "test" }

preferences:
192.59 ms | 402 KiB | 179 Q