3v4l.org

run code in 300+ PHP versions simultaneously
<?php // This function will take $_SERVER['REQUEST_URI'] and build a breadcrumb based on the user's current path function breadcrumbs($separator = ' &raquo; ', $home = 'Home') { // This gets the REQUEST_URI (/path/to/file.php), splits the string (using '/') into an array, and then filters out any empty values $path = array_filter(explode('/', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))); // This will build our "base URL" ... Also accounts for HTTPS :) $base = ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/'; // Initialize a temporary array with our breadcrumbs. (starting with our home page, which I'm assuming will be the base URL) $breadcrumbs = array("<a href=\"$base\">$home</a>"); // Find out the index for the last value in our path array $last = end(array_keys($path)); // Build the rest of the breadcrumbs foreach ($path AS $x => $crumb) { // Our "title" is the text that will be displayed (strip out .php and turn '_' into a space) $title = ucwords(str_replace(array('.php', '_'), array('', ' '), $crumb)); // If we are not on the last index, then display an <a> tag if ($x != $last) $breadcrumbs[] = "<a href=\"$base$crumb\">$title</a>"; // Otherwise, just display the title (minus) else $breadcrumbs[] = $title; } // Build our temporary array (pieces of bread) into one big string :) return implode($separator, $breadcrumbs); } echo breadcrumbs();
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key "REQUEST_URI" in /in/lGej4 on line 6 Deprecated: parse_url(): Passing null to parameter #1 ($url) of type string is deprecated in /in/lGej4 on line 6 Warning: Undefined array key "HTTPS" in /in/lGej4 on line 9 Warning: Undefined array key "HTTP_HOST" in /in/lGej4 on line 9 Notice: Only variables should be passed by reference in /in/lGej4 on line 15 <a href="http:///">Home</a>

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:
55.99 ms | 402 KiB | 8 Q