3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Doll { function __invoke(); } class LargeDoll implements Doll { private $inner; function __construct(Doll $inner) { $this->inner = $inner; } function __invoke() { return ($this->inner)() . ' world'; } } class SmallDoll implements Doll { function __invoke() { return 'hello'; } } $russian = new LargeDoll(new SmallDoll()); var_dump($russian());
Output for 7.0.0 - 7.0.31, 7.1.0 - 7.1.23, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.24, 8.3.0 - 8.3.12
string(11) "hello world"
Output for 5.6.38
Parse error: syntax error, unexpected '(' in /in/NsfQ0 on line 19
Process exited with code 255.

preferences:
83.1 ms | 406 KiB | 5 Q