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.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.14
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:
70.29 ms | 408 KiB | 5 Q