3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A extends \ArrayObject { protected $foo; public function __construct() { $this->foo = 'bar'; } public function serialize() { unset($this->foo); $result = parent::serialize(); $this->foo = 'bar'; return $result; } } $a = new A(); $a->append('item1'); $a->append('item2'); $a->append('item3'); $b = new A(); echo 'Serialized string: ' . $a->serialize() . PHP_EOL; $b->unserialize($a->serialize()); var_dump($b); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of A::serialize() should either be compatible with ArrayObject::serialize(): string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/v353G on line 11 Serialized string: x:i:0;a:3:{i:0;s:5:"item1";i:1;s:5:"item2";i:2;s:5:"item3";};m:a:0:{} object(A)#2 (2) { ["foo":protected]=> string(3) "bar" ["storage":"ArrayObject":private]=> array(3) { [0]=> string(5) "item1" [1]=> string(5) "item2" [2]=> string(5) "item3" } }

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:
113.46 ms | 407 KiB | 5 Q