3v4l.org

run code in 200+ 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 $this->${val}; // outputs "hi" echo "\n"; echo $this->val; //outputs "howdy" echo "\n"; echo $this->{"val"}; } } $foo = new foo();
based on UdeTq
Output for 7.2.0
hello Warning: Use of undefined constant val - assumed 'val' (this will throw an Error in a future version of PHP) in /in/n8jEZ on line 15 hi howdy howdy
Output for 5.3.19 - 7.1.10
hello Notice: Use of undefined constant val - assumed 'val' in /in/n8jEZ on line 15 hi howdy howdy