3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X { private array $code = []; function foo() { return (string) $this<-code; } } var_dump((new X)->foo());
Output for 8.3.5 - 8.3.30, 8.4.9 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught Error: Object of class X could not be converted to string in /in/RSmGR:7 Stack trace: #0 /in/RSmGR(11): X->foo() #1 {main} thrown in /in/RSmGR on line 7
Process exited with code 255.
Output for 5.6.40
Parse error: syntax error, unexpected 'array' (T_ARRAY), expecting variable (T_VARIABLE) in /in/RSmGR on line 4
Process exited with code 255.

preferences:
40.43 ms | 527 KiB | 4 Q