src/Uri/UriGenerator.php
public function segment($num = null)
    {
        if (is_null(http()->server('REQUEST_URI')) || is_null(http()->server('SCRIPT_NAME'))) {
            return null;
        }

        if (! is_null($num)) {
            $uri = $this->replace(str_replace($this->base, '', http()->server('REQUEST_URI')));
            $uriA = explode('/', $uri);
            return (isset($uriA[$num]) ? reset(explode('?', $uriA[$num])) : null);
        }

        return null;
    }
public function segment($num = null)
    {
        if (is_null(http()->server('REQUEST_URI')) || is_null(http()->server('SCRIPT_NAME'))) {
            return null;
        }

        if (! is_null($num)) {
            $uri = $this->replace(str_replace($this->base, '', http()->server('REQUEST_URI')));
            $uriA = explode('/', $uri);
            return (isset($uriA[$num]) ? reset(explode('?', $uriA[$num])) : null);
        }

        return null;
    }
Get segments of URI.

@param int $num

@return string | null