Last active
August 29, 2015 14:08
-
-
Save ronan-gloo/e4f963915ab62f6bcf23 to your computer and use it in GitHub Desktop.
unserialize callback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function unserialize_callback($className) { | |
if (! class_exists($className)) { | |
throw new RuntimeException('class not found: ' . $className); | |
} else { | |
throw new RuntimeException('deserialization of ' . $className . ' failed'); | |
} | |
} | |
ini_set('unserialize_callback_func', 'unserialize_callback'); | |
try { | |
$o = unserialize('O:4:"Test":0:{}'); | |
} | |
catch (\Exception $e) { | |
echo $e->getMessage(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment