3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait MyTrait { private $abc = 1; public function increment() { $this->abc++; } public function getValue() { return $this->abc; } } class MyClass { use MyTrait; public function incrementBy2() { $this->increment(); $this->abc++; } } $c = new MyClass; $c->incrementBy2(); var_dump($c->getValue());
Output for 7.1.6
int(3)