3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // Changement de classe à la volée class A { function change() { $this = new B(); } } class B { } $test = new A(); echo "test is class ".get_class($test)."\n"; $test->change(); echo "test is class ".get_class($test)."\n";
Output for 5.0.0 - 5.4.26
Fatal error: Cannot re-assign $this in /in/AesWa on line 8
Process exited with code 255.
Output for 4.3.0 - 4.4.9
test is class a test is class b