3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { public static $foo = 'foo'; public $thisvars = array(); public $selfvars = array(); public $staticvars = array(); public function __construct() { $this->addFoo(); } public function addFoo() { $this->selfvars[] = self::$foo; $this->staticvars[] = static::$foo; $this->thisvars[] = $this::$foo; } } class B extends A { public static $foo = 'bar'; public function __construct() { parent::__construct(); $this->addFoo(); } } $b = new B; print_r($b->selfvars); print_r($b->staticvars); print_r($b->thisvars); class C { public static $foo = 'foo'; public $vars = array(); public function __construct() { $this->addFoo(__CLASS__); } public function addFoo($class) { $this->vars[] = $class::$foo; } } class D extends C { public static $foo = 'bar'; public function __construct() { parent::__construct(); $this->addFoo(__CLASS__); } } $d = new D; print_r($d->vars);
Output for rfc.property-hooks, git.master, git.master_jit
Array ( [0] => foo [1] => foo ) Array ( [0] => bar [1] => bar ) Array ( [0] => bar [1] => bar ) Array ( [0] => foo [1] => bar )

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:
48.77 ms | 1541 KiB | 4 Q