3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class weird { var $myvar; var $other; var $blee = 'bleeblee'; var $bla; function __construct() { $myvar = 'other'; ${'myvar'} = 'blee'; ${'$myvar'} = 'bla'; $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 mvKE5
Output for 7.1.0 - 7.2.0
this->myvar: A this->$myvar: C this->${'myvar'}: C this->${'$myvar'}: D Notice: Undefined variable: blee in /in/PEfk7 on line 24 Notice: Undefined property: weird::$ in /in/PEfk7 on line 24 this->$$$$$$$myvar: Notice: Undefined variable: $$$myvar in /in/PEfk7 on line 27 Notice: Undefined variable: in /in/PEfk7 on line 27 Notice: Undefined variable: in /in/PEfk7 on line 27 Notice: Undefined variable: in /in/PEfk7 on line 27 Notice: Undefined variable: in /in/PEfk7 on line 27 Notice: Undefined variable: in /in/PEfk7 on line 27 Notice: Undefined variable: in /in/PEfk7 on line 27 Notice: Undefined property: weird::$ in /in/PEfk7 on line 27 this->$$$$$$${'$$$myvar'}:
Output for 7.0.0 - 7.0.20
this->myvar: A this->$myvar: C this->${'myvar'}: C this->${'$myvar'}: D Notice: Undefined variable: blee in /in/PEfk7 on line 24 Fatal error: Uncaught Error: Cannot access empty property in /in/PEfk7:24 Stack trace: #0 /in/PEfk7(32): weird->__construct() #1 {main} thrown in /in/PEfk7 on line 24
Process exited with code 255.
Output for 5.3.20 - 5.6.28
this->myvar: A this->$myvar: C this->${'myvar'}: C this->${'$myvar'}: D Notice: Undefined variable: blee in /in/PEfk7 on line 24 Fatal error: Cannot access empty property in /in/PEfk7 on line 24
Process exited with code 255.