3v4l.org

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