3v4l.org

run code in 500+ PHP versions simultaneously
<?php //class Foo class Foo implements \Serializable { public $a = 'lorem'; public function __wakeup() { fprintf(STDOUT, "in %s\n", __METHOD__); } public function serialize() { fprintf(STDOUT, "in %s\n", __METHOD__); return serialize([ $this->a, ]); } public function unserialize($serialized) { fprintf(STDOUT, "in %s\n", __METHOD__); list( $this->a, ) = unserialize($serialized); } } //$foo = new Foo(); //var_dump(serialize($foo)); //exit; $serialised = 'O:3:"Foo":1:{s:1:"a";s:5:"lorem";}'; //$serialised = 'C:3:"Foo":22:{a:1:{i:0;s:5:"lorem";}}'; $foo = unserialize($serialised); var_dump($foo);
Output for 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Deprecated: Foo implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /in/SHaCP on line 4 Warning: Erroneous data format for unserializing 'Foo' in /in/SHaCP on line 39 Warning: unserialize(): Error at offset 13 of 34 bytes in /in/SHaCP on line 39 bool(false)
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30
Deprecated: Foo implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /in/SHaCP on line 4 Warning: Erroneous data format for unserializing 'Foo' in /in/SHaCP on line 39 Notice: unserialize(): Error at offset 13 of 34 bytes in /in/SHaCP on line 39 bool(false)
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
Warning: Erroneous data format for unserializing 'Foo' in /in/SHaCP on line 39 Notice: unserialize(): Error at offset 13 of 34 bytes in /in/SHaCP on line 39 bool(false)
Output for 7.3.32 - 7.3.33
Warning: Erroneous data format for unserializing 'Foo' in /in/SHaCP on line 39 bool(false)

preferences:
109.38 ms | 1459 KiB | 4 Q