3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class weird { var $myvar; var $other; var $blee; function __construct() { $myvar = 'other'; ${'myvar'} = 'blee'; $this->myvar = "A"; $this->$myvar = "B"; $this->${'$myvar'} = "C"; echo 'this->myvar: '.$this->myvar."\n"; echo 'this->$myvar: '.$this->$myvar."\n"; echo 'this->${\'$myvar\'}: '.$this->${'$myvar'}."\n"; } } $obj = new weird;
based on QoRvd
Output for 7.1.0 - 7.2.0
Notice: Undefined variable: $myvar in /in/7Gr9K on line 14 this->myvar: A this->$myvar: B Notice: Undefined variable: $myvar in /in/7Gr9K on line 18 this->${'$myvar'}: C
Output for 7.0.0 - 7.0.20
Notice: Undefined variable: $myvar in /in/7Gr9K on line 14 Fatal error: Uncaught Error: Cannot access empty property in /in/7Gr9K:14 Stack trace: #0 /in/7Gr9K(23): weird->__construct() #1 {main} thrown in /in/7Gr9K on line 14
Process exited with code 255.
Output for 5.3.20 - 5.6.28
Notice: Undefined variable: $myvar in /in/7Gr9K on line 14 Fatal error: Cannot access empty property in /in/7Gr9K on line 14
Process exited with code 255.