3v4l.org

run code in 300+ PHP versions simultaneously
<?php function l($name) { $a = ["a" => "aaa", "b.a" => "123456", "a.d.e" => "1%1"]; $keys = explode(".", $name); $key = array_shift($keys); $result = isset($a[$key]) ? $a[$key] : null; print $result; foreach($keys as $k) { if(!$result) return $name; $result = $result[$k]; } $args = func_get_args(); foreach($args as $k => $v) $result = str_replace("%{$k}", $v, $result); return $result; } var_dump(l("a")); var_dump(l("b.a")); var_dump(l("b.c")); var_dump(l("a.d.e", 45));
Output for git.master, git.master_jit, rfc.property-hooks
aaastring(3) "aaa" string(3) "b.a" string(3) "b.c" aaa Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/GohWM:19 Stack trace: #0 /in/GohWM(31): l('a.d.e', 45) #1 {main} thrown in /in/GohWM on line 19
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:
40.77 ms | 401 KiB | 8 Q