3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class B { } class A { public function M() { echo("this=" . get_class($this) . "\n"); $x = "this"; $$x = new B(); echo("this=" . get_class($this) . "\n"); } } $a = new A(); $a->M();
Output for 7.1.0 - 7.2.0
this=A Fatal error: Uncaught Error: Cannot re-assign $this in /in/TdZJt:12 Stack trace: #0 /in/TdZJt(19): A->M() #1 {main} thrown in /in/TdZJt on line 12
Process exited with code 255.
Output for 5.3.18 - 7.0.20
this=A this=B