3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { protected $bar; } class bar extends foo { } $test = new bar(); $meh = serialize($test); $meh = unserialize($meh, ['allowed_classes' => 'foo']);
Output for 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 TypeError: unserialize(): Option "allowed_classes" must be of type array|bool, string given in /in/d3mus:14 Stack trace: #0 /in/d3mus(14): unserialize('O:3:"bar":1:{s:...', Array) #1 {main} thrown in /in/d3mus on line 14
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: unserialize(): allowed_classes option should be array or boolean in /in/d3mus on line 14
Output for 7.0.0 - 7.0.20
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Warning: unserialize() expects exactly 1 parameter, 2 given in /in/d3mus on line 14

preferences:
196.25 ms | 402 KiB | 244 Q