3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $a; private $b; public function __construct($a) { $this->a = $a; $this->b = $a; } public function __sleep() { return array('a', 'b'); } public function __wakeUp() { $this->__construct($this->a); } public function getA() { return $this->a; } public function getB() { return $this->b; } } class B implements \Serializable { private $a; private $b; public function __construct($a) { $this->a = $a; $this->b = $a; } public function serialize() { return serialize(array($this->a, $this->b)); } public function unserialize($serialized) { list($this->a, $this->b) = unserialize($serialized); $this->__construct($this->a); } public function getA() { return $this->a; } public function getB() { return $this->b; } } class C { private $a; private $b; public function __construct($a) { $this->a = $a; $this->b = $a; } public function getA() { return $this->a; } public function getB() { return $this->b; } } class D extends \ReflectionClass { public function __sleep() { return array('name'); } public function __wakeUp() { $this->__construct($this->name); } } $a = new A('a'); $b = new B('b'); $c = new C('c'); $d = new D('stdClass'); $serializedA = serialize($a); $serializedB = serialize($b); $serializedC = serialize($c); $serializedD = serialize($d); var_dump($serializedA); var_dump($serializedB); var_dump($serializedC); var_dump($serializedD); var_dump(unserialize($serializedD));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: B 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/S7Dco on line 35 Fatal error: Uncaught Exception: Serialization of 'D' is not allowed in /in/S7Dco:112 Stack trace: #0 /in/S7Dco(112): serialize(Object(D)) #1 {main} thrown in /in/S7Dco on line 112
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
38.89 ms | 402 KiB | 8 Q