3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class foo { function __construct() { $this->a = "hello"; $this->b = "hi"; $this->val = "howdy"; $val = "a"; echo $this->{$val}; // outputs "hello" echo "\n"; $val = "b"; echo $$b; // outputs "hi" echo "\n"; echo $$val; //outputs "howdy" echo "\n"; echo $$val; } } $foo = new foo();
based on UdeTq
Output for 5.0.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
hello Notice: Undefined variable: b in /in/Bv6M3 on line 15 Notice: Undefined variable: in /in/Bv6M3 on line 15 Notice: Undefined variable: b in /in/Bv6M3 on line 18 Notice: Undefined variable: b in /in/Bv6M3 on line 21
Output for 5.0.0 - 5.0.3
hello Notice: Undefined variable: b in /in/Bv6M3 on line 15 Notice: Undefined variable: in /in/Bv6M3 on line 15 Notice: Undefined variable: b in /in/Bv6M3 on line 18 Notice: Undefined variable: b in /in/Bv6M3 on line 21
Output for 4.3.0 - 4.4.9