3v4l.org

run code in 300+ PHP versions simultaneously
<?php Class A { public $property; public function __construct( $prop ) { $this->property = $prop; } public function returnValue(){ return static::${this->property}; } } Class B extends A { public static $property_one = 'This is first property'; public static $property_two = 'This is second property'; } $B = new B( 'property_one' ); $B->returnValue();
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Undefined constant "this" in /in/2Veqt:12 Stack trace: #0 /in/2Veqt(25): A->returnValue() #1 {main} thrown in /in/2Veqt on line 12
Process exited with code 255.
Output for 5.4.0 - 5.4.22
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /in/2Veqt on line 12
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/2Veqt on line 12
Process exited with code 255.

preferences:
96.59 ms | 401 KiB | 79 Q