3v4l.org

run code in 300+ PHP versions simultaneously
<?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());

preferences:
39.42 ms | 402 KiB | 5 Q