3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait aTrait { public static function build($x) { return new static($x); } } class A { public function __construct($x) { $this->x = $x; } use aTrait; } class B { public function __construct($x) { $this->x = $x * 2; } use aTrait; } $a = A::build(2); $b = B::build(2); var_dump($a); var_dump($b);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property A::$x is deprecated in /in/BogSt on line 12 Deprecated: Creation of dynamic property B::$x is deprecated in /in/BogSt on line 20 object(A)#1 (1) { ["x"]=> int(2) } object(B)#2 (1) { ["x"]=> int(4) }

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:
32.95 ms | 406 KiB | 5 Q