3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class foo { function __construct($arr) { $this = $arr; $this->a = "hello"; $this->b = "hi"; $this->val = "howdy"; echo $this->a; echo "\n"; echo $this->b; echo "\n"; $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"}; } } $arr = array('a'=>'1','b'=>'2','c'=>'3'); $foo = new foo($arr);
Output for 5.0.0 - 5.4.27
Fatal error: Cannot re-assign $this in /in/cOao5 on line 4
Process exited with code 255.
Output for 4.3.0 - 4.4.9