3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Randoz{ public function between0And10():int { return rand(0,10); } } interface RndCounter { function randomInt():int; function between0And10():int; } function create(): RndCounter { return new class() implements RndCounter { use Randoz; function randomInt():int { return rand(); } }; } $counter = create(); echo $counter->randomInt()." - ".$counter->between0And10();

preferences:
36.82 ms | 402 KiB | 5 Q