3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test { protected $a = 'ciao'; public function salute() { $this->a = 'a'; echo $this->$a; } public function __get($name) { var_dump($name); return $this->$name; } } $test = new test(); $test->salute();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Warning: Undefined variable $a in /in/44r0g on line 9 string(0) "" Warning: Undefined property: test::$ in /in/44r0g on line 15
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: a in /in/44r0g on line 9 string(0) "" Notice: Undefined property: test::$ in /in/44r0g on line 15
Output for 7.3.32 - 7.3.33
string(0) ""
Output for 7.0.0 - 7.0.20
Notice: Undefined variable: a in /in/44r0g on line 9 string(0) "" Fatal error: Uncaught Error: Cannot access empty property in /in/44r0g:15 Stack trace: #0 /in/44r0g(9): test->__get('') #1 /in/44r0g(20): test->salute() #2 {main} thrown in /in/44r0g on line 15
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Notice: Undefined variable: a in /in/44r0g on line 9 string(0) "" Fatal error: Cannot access empty property in /in/44r0g on line 15
Process exited with code 255.

preferences:
181.06 ms | 402 KiB | 185 Q