3v4l.org

run code in 300+ PHP versions simultaneously
<?php $r= new ReflectionClass(new class() { public function instance(): self { return $this; } }); $type= $r->getMethod('instance')->getReturnType(); var_dump($type->getName()); $o = new ($type->getName()); var_dump($o);
Output for git.master_jit, git.master
string(4) "self" Fatal error: Uncaught Error: Class "self" not found in /in/5D2aT:10 Stack trace: #0 {main} thrown in /in/5D2aT on line 10
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
57.45 ms | 405 KiB | 5 Q