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.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
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:
59.97 ms | 406 KiB | 5 Q