3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait TraitName{ protected $name; abstract protected function setName(); public function __construct(){ $this->setName(); } public function getName(){ return $this->name; } } class MyClass{ use TraitName{ TraitName::__construct as private __traitConstruct; } protected function setName(){ $this->name = __CLASS__; } public function __construct(){ $this->__traitConstruct(); } } $objMyClass = new MyClass(); echo $objMyClass->getName();
based on Qklah
Output for 5.4.11 - 7.2.6
MyClass
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/trefq on line 3
Process exited with code 255.