3v4l.org

run code in 300+ PHP versions simultaneously
<?php class x { function __construct(){ $x=& $this; $x = new y; var_dump($this); } function foo(){ $this->bar(); } } class y{ function bar(){ echo "bar"; } } $b=new x; $b->__construct();

preferences:
36.32 ms | 402 KiB | 5 Q