protected function buildUrl($baseUrl, $additionalUrl)
    {
        $baseUrl = parse_url($baseUrl);
        if (!is_array($additionalUrl)) {
            $additionalUrl = parse_url($additionalUrl);
        }

        if (isset($baseUrl['query'], $additionalUrl['query'])) {
            $additionalUrl['query'] = $baseUrl['query'] . '&' . $additionalUrl['query'];
        }

        $urlInfo = array_merge($baseUrl, $additionalUrl);
        $url = $urlInfo['scheme'] . '://'
            . (empty($urlInfo['username']) ? ''
                :(empty($urlInfo['password']) ? "{$urlInfo['username']}@"
                    :"{$urlInfo['username']}:{$urlInfo['password']}@"))
            . $urlInfo['host']
            . (empty($urlInfo['port']) ? '' : ":{$urlInfo['port']}")
            . (empty($urlInfo['path']) ? '' : $urlInfo['path'])
            . (empty($urlInfo['query']) ? '' : "?{$urlInfo['query']}")
            . (empty($urlInfo['fragment']) ? '' : "#{$urlInfo['fragment']}");

        return $url;
    }
protected function buildUrl($baseUrl, $additionalUrl)
    {
        $baseUrl = parse_url($baseUrl);
        if (!is_array($additionalUrl)) {
            $additionalUrl = parse_url($additionalUrl);
        }

        if (isset($baseUrl['query'], $additionalUrl['query'])) {
            $additionalUrl['query'] = $baseUrl['query'] . '&' . $additionalUrl['query'];
        }

        $urlInfo = array_merge($baseUrl, $additionalUrl);
        $url = $urlInfo['scheme'] . '://'
            . (empty($urlInfo['username']) ? ''
                :(empty($urlInfo['password']) ? "{$urlInfo['username']}@"
                    :"{$urlInfo['username']}:{$urlInfo['password']}@"))
            . $urlInfo['host']
            . (empty($urlInfo['port']) ? '' : ":{$urlInfo['port']}")
            . (empty($urlInfo['path']) ? '' : $urlInfo['path'])
            . (empty($urlInfo['query']) ? '' : "?{$urlInfo['query']}")
            . (empty($urlInfo['fragment']) ? '' : "#{$urlInfo['fragment']}");

        return $url;
    }
protected function buildUrl ( $ baseUrl , $ additionalUrl ) { $ baseUrl = parse_url ( $ baseUrl ) ; if ( ! is_array ( $ additionalUrl ) ) { $ additionalUrl = parse_url ( $ additionalUrl ) ; } if ( isset ( $ baseUrl [ 'query' ] , $ additionalUrl [ 'query' ] ) ) { $ additionalUrl [ 'query' ] = $ baseUrl [ 'query' ] . '&' . $ additionalUrl [ 'query' ] ; } $ urlInfo = array_merge ( $ baseUrl , $ additionalUrl ) ; $ url = $ urlInfo [ 'scheme' ] . '://' . ( empty ( $ urlInfo [ 'username' ] ) ? '' : ( empty ( $ urlInfo [ 'password' ] ) ? "{$urlInfo['username']}@" : "{$urlInfo['username']}:{$urlInfo['password']}@" ) ) . $ urlInfo [ 'host' ] . ( empty ( $ urlInfo [ 'port' ] ) ? '' : ":{$urlInfo['port']}" ) . ( empty ( $ urlInfo [ 'path' ] ) ? '' : $ urlInfo [ 'path' ] ) . ( empty ( $ urlInfo [ 'query' ] ) ? '' : "?{$urlInfo['query']}" ) . ( empty ( $ urlInfo [ 'fragment' ] ) ? '' : "#{$urlInfo['fragment']}" ) ; return $ url ; }
Combines given URLs into single one.
@param string $baseUrl base URL.
@param string|array $additionalUrl additional URL string or information array.
@return string composed URL.
Combines given URLs into single one .