3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Sample URLs. In practice there'd just be one which comes from $_SERVER['REQUEST_URI'] $urls = [ 'https://example.com', 'https://example.com/', 'https://example.com/en', 'https://example.com/en/', 'https://example.com/en/something', 'https://example.com/en/something/cheese', 'https://example.com/en/something/cheese/stuff', ]; foreach($urls as $url){ $urlParts = parse_url($url); $path = $urlParts['path'] ?? '/'; $pathParts = array_values(array_filter(explode('/', $path))); $lang = $menu = $page = $key = null; echo 'Url tested: ' . $url; echo PHP_EOL; if(!$pathParts){ echo 'Home'; }else{ // I would probably write this with a switch on the count(pathParts), or do some better // parsing here maybe, but this just shows what could happen @[0 => $lang, 1 => $menu, 2 => $page, 3 => $key] = $pathParts; echo sprintf('Lang=%1$s, Menu=%2$s, Page=%3$s, Key=%4$s', $lang, $menu, $page, $key); } echo PHP_EOL, PHP_EOL; }
Output for git.master_jit, git.master, rfc.property-hooks
Url tested: https://example.com Home Url tested: https://example.com/ Home Url tested: https://example.com/en Lang=en, Menu=, Page=, Key= Url tested: https://example.com/en/ Lang=en, Menu=, Page=, Key= Url tested: https://example.com/en/something Lang=en, Menu=something, Page=, Key= Url tested: https://example.com/en/something/cheese Lang=en, Menu=something, Page=cheese, Key= Url tested: https://example.com/en/something/cheese/stuff Lang=en, Menu=something, Page=cheese, Key=stuff

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.81 ms | 1045 KiB | 4 Q