3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a { function __invoke() { echo("Invoked\n"); } } class b { private a $a; function doStuff() { $this->a = new a(); $this->a(); } } $b = new b(); $b->doStuff();
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught Error: Call to undefined method b::a() in /in/maHHa:12 Stack trace: #0 /in/maHHa(17): b->doStuff() #1 {main} thrown in /in/maHHa on line 12
Process exited with code 255.

preferences:
71.21 ms | 991 KiB | 4 Q