Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Test case for PHP serialization bug
class HelloWorld implements Serializable {
public $test;
public function __construct($str)
$this->test = $str;
public function serialize()
$simple = null;
$simple = new Simple();
$simple->test = $this->test;
return serialize($simple);
public function unserialize($str)
$simple = unserialize($str);
$this->test = $simple->test;
class Simple
public $test;
$list = array(
new HelloWorld('str1'),
new HelloWorld('str2'),
new HelloWorld('str3'),
new HelloWorld('str4'),
new HelloWorld('str5'),
new HelloWorld('str6'),
new HelloWorld('str7'),
new HelloWorld('str8'),
new HelloWorld('str9'),
$str = serialize($list);
echo $str . "\n";
// var_dump(unserialize($str));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.