3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait Foo { private $traitProperty = 'blah'; public function getTraitProperty() { return $this->traitProperty; } public function getClassPropertyFromTrait() { return $this->classProperty; } } class MyClass { use Foo; private $classProperty = 'meh'; public function getTraitPropertyFromClass() { return $this->traitProperty; } public function getClassProperty() { return $this->classProperty; } } $x = new MyClass(); var_dump($x->getTraitProperty()); var_dump($x->getTraitPropertyFromClass()); var_dump($x->getClassProperty()); var_dump($x->getClassPropertyFromTrait());

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Typed properties v2
string(4) "blah" string(4) "blah" string(3) "meh" string(3) "meh"
Output for Arrow functions
string(4) "blah" string(4) "blah" string(3) "meh" string(3) "meh"
Output for Object typehint
string(4) "blah" string(4) "blah" string(3) "meh" string(3) "meh"
Output for Array change keys
string(4) "blah" string(4) "blah" string(3) "meh" string(3) "meh"
Output for Lexical anon
string(4) "blah" string(4) "blah" string(3) "meh" string(3) "meh"

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