3v4l.org

run code in 500+ PHP versions simultaneously
<?php class X { private array $code = []; function foo() { return (string) $this<-code; } } var_dump((new X)->foo());
Output for 8.2.31, 8.3.5 - 8.3.31, 8.4.9 - 8.4.22, 8.5.0 - 8.5.7
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:
39.58 ms | 557 KiB | 4 Q