3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test { var $foo = "bar"; function abc() { var_dump($this); echo "<br />"; var_dump($this->foo); echo "<hr />"; $thisStr = "this"; $$thisStr = "Hello!"; var_dump($this); echo "<br />"; } } $test = new Test(); $test->abc();
based on JNtYD
Output for 7.1.0 - 7.2.0
object(Test)#1 (1) { ["foo"]=> string(3) "bar" } <br />string(3) "bar" <hr /> Fatal error: Uncaught Error: Cannot re-assign $this in /in/7rMe1:13 Stack trace: #0 /in/7rMe1(20): Test->abc() #1 {main} thrown in /in/7rMe1 on line 13
Process exited with code 255.
Output for 5.3.21 - 7.0.20
object(Test)#1 (1) { ["foo"]=> string(3) "bar" } <br />string(3) "bar" <hr />string(6) "Hello!" <br />