3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Base { private $foo; public function __construct() { $this->foo = "base foo"; } public final function getFoo() { var_dump($this); return $this->foo; } } class Derived extends Base { public $foo; public function __construct($type) { parent::__construct(); $this->foo = "derived foo"; $this->somethingUndefined = "dynamically declared"; } } $base = new Base(); var_dump($base->getFoo()); $derived = new Derived(0); var_dump($derived->getFoo()); $clonedDerived = clone $derived; var_dump($clonedDerived->getFoo());
Output for git.master, git.master_jit, rfc.property-hooks
object(Base)#1 (1) { ["foo":"Base":private]=> string(8) "base foo" } string(8) "base foo" Deprecated: Creation of dynamic property Derived::$somethingUndefined is deprecated in /in/Ob9m7 on line 24 object(Derived)#2 (3) { ["foo":"Base":private]=> string(8) "base foo" ["foo"]=> string(11) "derived foo" ["somethingUndefined"]=> string(20) "dynamically declared" } string(8) "base foo" object(Derived)#3 (3) { ["foo":"Base":private]=> string(8) "base foo" ["foo"]=> string(11) "derived foo" ["somethingUndefined"]=> string(20) "dynamically declared" } string(8) "base foo"

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