3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class weird { var $myvar; var $other; var $blee; 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 QoRvd
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/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined property: weird::$ in /in/feoW8 on line 23 this->$$$$$$$myvar: Notice: Undefined variable: $$$myvar in /in/feoW8 on line 25 Notice: Undefined variable: in /in/feoW8 on line 25 Notice: Undefined variable: in /in/feoW8 on line 25 Notice: Undefined variable: in /in/feoW8 on line 25 Notice: Undefined variable: in /in/feoW8 on line 25 Notice: Undefined variable: in /in/feoW8 on line 25 Notice: Undefined variable: in /in/feoW8 on line 25 Notice: Undefined property: weird::$ in /in/feoW8 on line 25 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/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Fatal error: Uncaught Error: Cannot access empty property in /in/feoW8:23 Stack trace: #0 /in/feoW8(30): weird->__construct() #1 {main} thrown in /in/feoW8 on line 23
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/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Notice: Undefined variable: in /in/feoW8 on line 23 Fatal error: Cannot access empty property in /in/feoW8 on line 23
Process exited with code 255.