3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Errors { private $error; private function _init(){ $this->errors = (object) [ 'small' => 'Small mistake' ]; } public function getError(){ var_dump($this->errors); } } class Test { use Errors; public function __construct(){ $this->errors = $this->_init(); } } $obj = new Test(); $obj->getError();

preferences:
30.07 ms | 402 KiB | 5 Q