3v4l.org

run code in 300+ PHP versions simultaneously
<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><?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();</span> <? Php class foo {function __ construct () {$ this-> a = "bonjour"; $ this-> b = "salut"; $ this-> val = "allo"; $ val = "a"; echo $ this-> {$ val}; / / affiche "bonjour" echo "\ n"; $ val = "b"; echo $ this-> {$ val}; / / affiche "salut" echo "\ n"; echo $ this-> val; / / affiche "Howdy" echo "\ n"; echo $ this-> {"val"};}} $ foo = new foo ();</span>
Output for 5.4.0 - 5.4.17
Parse error: syntax error, unexpected end of file in /in/4b2kQ on line 1
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected $end in /in/4b2kQ on line 1
Process exited with code 255.

preferences:
199.15 ms | 1395 KiB | 53 Q