3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $x; public $y; public function __construct($x, $y) { $this->x = sha1($x); $this->y = $y; } public function __clone() { return new A($this->x, $this->y); } } class B extends A { public $z; public function __construct($z, $parent_obj) { $this->z = $z; parent::__construct($parent_obj->x, $parent_obj->y); } public function doSomeThing() { $parent_a_array = (array) parent::__clone(); var_dump($parent_a_array); $child_a_array = array_diff_assoc((array) $this, $parent_a_array); var_dump($child_a_array); echo "Parent Array Printing :\n"; foreach ($parent_a_array as $key => $value) { echo "Key: $key; Value: $value\n"; } echo "\nChild Array Printing: \n"; foreach ($child_a_array as $key => $value) { echo "Key: $key; Value: $value\n"; } } } $t = new B('C', new A("A", "B")); $t->doSomeThing();
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { ["x"]=> string(40) "726c6aeb8252ad589562fe2c7409d50c90a058aa" ["y"]=> string(1) "B" } array(2) { ["x"]=> string(40) "bd605412133b28b10c5fa7a45fce29df67c18bd7" ["z"]=> string(1) "C" } Parent Array Printing : Key: x; Value: 726c6aeb8252ad589562fe2c7409d50c90a058aa Key: y; Value: B Child Array Printing: Key: x; Value: bd605412133b28b10c5fa7a45fce29df67c18bd7 Key: z; Value: C

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:
56.33 ms | 402 KiB | 8 Q