3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements Stringable { const HOGE = 'hoge'; public function __toString(): string { return 'HOGE'; } } function f(Stringable $name): void { var_dump(Foo::{(string)$name}); var_dump(Foo::{$name}); } f(new Foo);
Output for git.master_jit, git.master
string(4) "hoge" Fatal error: Uncaught TypeError: Cannot use value of type object as class constant name in /in/WZTCC:14 Stack trace: #0 /in/WZTCC(17): f(Object(Foo)) #1 {main} thrown in /in/WZTCC on line 14
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:
25.86 ms | 405 KiB | 5 Q