Created
September 14, 2010 02:21
-
-
Save isaiahdw/578424 to your computer and use it in GitHub Desktop.
This file contains 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 | |
set_error_handler('my_error_handler'); | |
session_start(); | |
class myclass implements Serializable | |
{ | |
private $a = 1; | |
private $b = 2; | |
public function serialize() | |
{ | |
return serialize($this->a); | |
} | |
public function unserialize($data) | |
{ | |
$this->a = unserialize($data); | |
} | |
} | |
function my_error_handler($code, $error, $file = NULL, $line = NULL) | |
{ | |
throw new ErrorException($error, $code, 0, $file, $line); | |
} | |
$obj = new myclass(); | |
$_SESSION['obj'] = serialize($obj); | |
$a->b(); | |
// __sleep/__wakeup | |
// obj|O:7:"myclass":2:{s:10:"myclassa";i:1;s:10:"myclassb";i:2;} (Fatal error) | |
// obj|O:7:"myclass":1:{s:10:"myclassa";i:1;} (No fatal error) | |
// Serializable | |
// obj|s:22:"C:7:"myclass":4:{i:1;}"; (No fatal error) | |
// obj|s:22:"C:7:"myclass":4:{i:1;}"; (Fatal error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment