3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $functionArray = ['myFunc' => 'yourFunc']; 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";
Output for git.master, git.master_jit
Foo Value Warning: Array to string conversion in /in/Naq7H on line 30 Warning: Undefined property: Foo::$Array in /in/Naq7H on line 30 Warning: Trying to access array offset on value of type null in /in/Naq7H on line 30 Fatal error: Uncaught Error: Value of type null is not callable in /in/Naq7H:30 Stack trace: #0 {main} thrown in /in/Naq7H on line 30
Process exited with code 255.
Output for rfc.property-hooks
Foo Value Warning: Array to string conversion in /in/Naq7H on line 30 Warning: Undefined property: Foo::$Array in /in/Naq7H on line 30 Warning: Trying to access array offset on null in /in/Naq7H on line 30 Fatal error: Uncaught Error: Value of type null is not callable in /in/Naq7H:30 Stack trace: #0 {main} thrown in /in/Naq7H 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:
64.06 ms | 405 KiB | 9 Q