3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { const MYARRAY = ['foo' => 'bar']; protected static $props = ['Hello' => 'Foo Value']; function getPropValue($propName) { return static::$props[$propName]; } function myFunc() { return 'hey myFunc'; } function yourFunc() { return 'hey yourFunc'; } } class Bar extends Foo { protected static $props = ['Hello' => 'Bar Value']; } $foo = new Foo(); echo $foo->getPropValue('Hello') . "\n\n"; $functionArray = ['myFunc' => 'myFunc']; echo $foo->$functionArray['myFunc']() . "\n\n"; $bar = new Bar(); echo $bar->getPropValue('Hello') . "\n\n"; if (isset(Foo::MYARRAY['foo'])) { echo 'foo is set' . "\n\n"; } else { echo 'foo is not set' . "\n\n"; }
Output for git.master, git.master_jit
Foo Value Warning: Array to string conversion in /in/0UC54 on line 30 Warning: Undefined property: Foo::$Array in /in/0UC54 on line 30 Warning: Trying to access array offset on value of type null in /in/0UC54 on line 30 Fatal error: Uncaught Error: Value of type null is not callable in /in/0UC54:30 Stack trace: #0 {main} thrown in /in/0UC54 on line 30
Process exited with code 255.
Output for rfc.property-hooks
Foo Value Warning: Array to string conversion in /in/0UC54 on line 30 Warning: Undefined property: Foo::$Array in /in/0UC54 on line 30 Warning: Trying to access array offset on null in /in/0UC54 on line 30 Fatal error: Uncaught Error: Value of type null is not callable in /in/0UC54:30 Stack trace: #0 {main} thrown in /in/0UC54 on line 30
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:
38.93 ms | 401 KiB | 8 Q