3v4l.org

run code in 150+ 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 />"; var_dump($this->foo); } } $test = new Test(); $test->abc();
Output for 7.1.0
object(Test)#1 (1) { ["foo"]=> string(3) "bar" } <br />string(3) "bar" <hr /> Fatal error: Uncaught Error: Cannot re-assign $this in /in/uMMrG:13 Stack trace: #0 /in/uMMrG(23): Test->abc() #1 {main} thrown in /in/uMMrG on line 13
Process exited with code 255.
Output for 5.1.3 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.14
object(Test)#1 (1) { ["foo"]=> string(3) "bar" } <br />string(3) "bar" <hr />string(6) "Hello!" <br />string(3) "bar"
Output for 5.0.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/uMMrG on line 4 object(Test)#1 (1) { ["foo"]=> string(3) "bar" } <br />string(3) "bar" <hr />string(6) "Hello!" <br />string(3) "bar"
Output for 4.3.0 - 4.4.9
object(test)(1) { ["foo"]=> string(3) "bar" } <br />string(3) "bar" <hr />string(6) "Hello!" <br />NULL