* // Get the first segment of the request URI * $segment = URI::segment(1); * * // Get the second segment of the URI, or return a default value * $segment = URI::segment(2, 'Taylor'); * * * @param int $index * @param mixed $default * @return string */ public static function segment($index, $default = null) { static::current(); return array_get(static::$segments, $index - 1, $default); } /** * Set the URI segments for the request. * * @param string $uri * @return void */ protected static function segments($uri) { $segments = explode('/', trim($uri, '/')); static::$segments = array_diff($segments, array('')); } /** * Remove a given value from the URI. * * @param string $uri * @param string $value * @return string */ protected static function remove($uri, $value) { return (strpos($uri, $value) === 0) ? substr($uri, strlen($value)) : $uri; } /** * Get the query string for the current request. * * @return string */ protected static function query() { return (count((array) $_GET) > 0) ? '?'.http_build_query($_GET) : ''; } }