Skip to content

Instantly share code, notes, and snippets.

@ronan-gloo
Last active August 29, 2015 14:08
Show Gist options
  • Save ronan-gloo/e4f963915ab62f6bcf23 to your computer and use it in GitHub Desktop.
Save ronan-gloo/e4f963915ab62f6bcf23 to your computer and use it in GitHub Desktop.
unserialize callback
<?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