3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $b = 'foo'; } class B extends A { public function __sleep() { return array('b'); } } class C extends A implements Serializable { public function unserialize($serialized) { /*... */ } public function serialize() { $b = new ReflectionProperty('C', 'b'); $b->setAccessible(true); return serialize(array('b' => $b->getValue($this))); } } var_dump(serialize(new A())); var_dump(serialize(new B())); var_dump(serialize(new C()));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: C 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/7gmJ5 on line 16 string(33) "O:1:"A":1:{s:4:"Ab";s:3:"foo";}" Warning: serialize(): "b" returned as member variable from __sleep() but does not exist in /in/7gmJ5 on line 28 string(12) "O:1:"B":0:{}" Fatal error: Uncaught ReflectionException: Property C::$b does not exist in /in/7gmJ5:21 Stack trace: #0 /in/7gmJ5(21): ReflectionProperty->__construct('C', 'b') #1 [internal function]: C->serialize() #2 /in/7gmJ5(29): serialize(Object(C)) #3 {main} thrown in /in/7gmJ5 on line 21
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:
40.96 ms | 402 KiB | 8 Q