3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function sugar_unserialize($value) { preg_match('/[oc]:\d+:/i', $value, $matches); if (count($matches)) { return false; } return unserialize($value); } $test1 = 'a:1:{i:0;O:8:"stdClass":0:{}}'; $test2 = 'a:1:{i:0;O:+8:"stdClass":0:{}}'; var_dump(sugar_unserialize($test1), sugar_unserialize($test2));
Output for 7.2.0 - 7.2.6
Notice: unserialize(): Error at offset 9 of 30 bytes in /in/5vaj9 on line 11 bool(false) bool(false)
Output for 5.5.0 - 5.6.30, 7.0.0 - 7.1.20
bool(false) array(1) { [0]=> object(stdClass)#1 (0) { } }
Output for hhvm-3.22.0
Notice: Unable to unserialize: [a:1:{i:0;O:+8:"stdClass":0:{}}]. Expected ':' but got '+'. in /in/5vaj9 on line -1 bool(false) bool(false)
Output for hhvm-3.12.14 - 3.21.3
Notice: Unable to unserialize: [a:1:{i:0;O:+8:"stdClass":0:{}}]. Expected ':' but got '+'. in /in/5vaj9 on line 11 bool(false) bool(false)