3v4l.org

run code in 300+ PHP versions simultaneously
<?php function apply($a, $f) { foreach ($a as $k => $v) { $f($k, $v); } } $f = function ($v, $k) { var_dump($k, $v); }; $g = function ($v) { var_dump($v); }; $h = 'strlen'; $a = ['a' => 'foo', 'b' => 'noodle', 'c' => 'derp']; apply($a, $f); apply($a, $g); apply($a, $h);
Output for git.master, git.master_jit, rfc.property-hooks
string(3) "foo" string(1) "a" string(6) "noodle" string(1) "b" string(4) "derp" string(1) "c" string(1) "a" string(1) "b" string(1) "c" Fatal error: Uncaught ArgumentCountError: strlen() expects exactly 1 argument, 2 given in /in/Ye37u:6 Stack trace: #0 /in/Ye37u(6): strlen('a', 'foo') #1 /in/Ye37u(21): apply(Array, 'strlen') #2 {main} thrown in /in/Ye37u on line 6
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:
47.22 ms | 401 KiB | 8 Q