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 = 'O:8:"stdClass":0:{}'; $test2 = 'O:+8:"stdClass":0:{}'; var_dump(sugar_unserialize($test1), sugar_unserialize($test2));
based on 5vaj9
Output for 7.2.0
Notice: unserialize(): Error at offset 0 of 20 bytes in /in/oc2cY on line 11 bool(false) bool(false)
Output for 5.0.0 - 5.6.30, 7.0.0 - 7.1.10
bool(false) object(stdClass)#1 (0) { }
Output for hhvm-3.10.1 - 3.17.3
Notice: Unable to unserialize: [O:+8:"stdClass":0:{}]. Expected ':' but got '+'. in /in/oc2cY on line 11 bool(false) bool(false)
Output for 4.3.0 - 4.4.9
bool(false) object(stdClass)(0) { }