3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { const x = '3.1415'; } class B extends A { public function getX() { return parent->x; } } $b = new B; echo $b->getX();
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Undefined constant "parent" in /in/uo99A:9 Stack trace: #0 /in/uo99A(15): B->getX() #1 {main} thrown in /in/uo99A on line 9
Process exited with code 255.
Output for 7.0.0 - 7.0.2
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ';' in /in/uo99A on line 9
Process exited with code 255.
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /in/uo99A on line 9
Process exited with code 255.

preferences:
72.73 ms | 402 KiB | 48 Q