3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo implements \Serializable { public $default = 10; public $setMe; private $test = 1; public $removeOnSerialize = 'blah'; public function serialize() { unset($this->removeOnSerialze); return serialize($this->getData()); } public function unserialize($serialized) { foreach (unserialize($serialized) as $key => $value) { $this->$key = $value; } $this->removeOnSerialize = 'Set some value'; } protected function getData() { return (array)$this; } } $obj = new Foo(); $obj->setMe = 9999; print_r($obj); // here I have all as exepcted $serialized = serialize($obj); $unserialized = unserialize($serialized); print_r($unserialized);
based on M3805
Output for 7.0.0 - 7.2.6
Foo Object ( [default] => 10 [setMe] => 9999 [test:Foo:private] => 1 [removeOnSerialize] => blah ) Fatal error: Uncaught Error: Cannot access property started with '\0' in /in/mqijs:19 Stack trace: #0 [internal function]: Foo->unserialize('a:4:{s:7:"defau...') #1 /in/mqijs(37): unserialize('C:3:"Foo":100:{...') #2 {main} thrown in /in/mqijs on line 19
Process exited with code 255.
Output for 5.6.0 - 5.6.24
Foo Object ( [default] => 10 [setMe] => 9999 [test:Foo:private] => 1 [removeOnSerialize] => blah ) Fatal error: Cannot access property started with '\0' in /in/mqijs on line 19
Process exited with code 255.