3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { private $functions = array( array('funcName' => 'FUNC1'), array('funcName' => 'FUNC2'), array('funcName' => 'FUNC3') ); function FUNC1() { echo 'FUNC1', PHP_EOL, PHP_EOL; } function FUNC2() { echo 'FUNC2', PHP_EOL, PHP_EOL; } function FUNC3() { echo 'FUNC3', PHP_EOL, PHP_EOL; } /** this worked only up to PHP 5.6.16 */ public function callAllFunctions() { foreach ($this->functions as $values) { echo 'call ', $values['funcName'], PHP_EOL; $this->$values['funcName'](); } } /** this code must be used in PHP 7.x public function callAllFunctions() { foreach ($this->functions as $values) { echo 'call ', $values['funcName'], PHP_EOL; $fncName = $values['funcName']; $this->$fncName(); } } */ } $test = new foo(); $test->callAllFunctions();
Output for git.master, git.master_jit
call FUNC1 Warning: Array to string conversion in /in/9pkEq on line 27 Warning: Undefined property: foo::$Array in /in/9pkEq on line 27 Warning: Trying to access array offset on value of type null in /in/9pkEq on line 27 Fatal error: Uncaught Error: Value of type null is not callable in /in/9pkEq:27 Stack trace: #0 /in/9pkEq(43): foo->callAllFunctions() #1 {main} thrown in /in/9pkEq on line 27
Process exited with code 255.
Output for rfc.property-hooks
call FUNC1 Warning: Array to string conversion in /in/9pkEq on line 27 Warning: Undefined property: foo::$Array in /in/9pkEq on line 27 Warning: Trying to access array offset on null in /in/9pkEq on line 27 Fatal error: Uncaught Error: Value of type null is not callable in /in/9pkEq:27 Stack trace: #0 /in/9pkEq(43): foo->callAllFunctions() #1 {main} thrown in /in/9pkEq on line 27
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:
49.58 ms | 401 KiB | 8 Q