src/Guzzle/Http/Url.php
public function combine($url, $strictRfc3986 = false)
    {
        $url = self::factory($url);

        // Use the more absolute URL as the base URL
        if (!$this->isAbsolute() && $url->isAbsolute()) {
            $url = $url->combine($this);
        }

        // Passing a URL with a scheme overrides everything
        if ($buffer = $url->getScheme()) {
            $this->scheme = $buffer;
            $this->host = $url->getHost();
            $this->port = $url->getPort();
            $this->username = $url->getUsername();
            $this->password = $url->getPassword();
            $this->path = $url->getPath();
            $this->query = $url->getQuery();
            $this->fragment = $url->getFragment();
            return $this;
        }

        // Setting a host overrides the entire rest of the URL
        if ($buffer = $url->getHost()) {
            $this->host = $buffer;
            $this->port = $url->getPort();
            $this->username = $url->getUsername();
            $this->password = $url->getPassword();
            $this->path = $url->getPath();
            $this->query = $url->getQuery();
            $this->fragment = $url->getFragment();
            return $this;
        }

        $path = $url->getPath();
        $query = $url->getQuery();

        if (!$path) {
            if (count($query)) {
                $this->addQuery($query, $strictRfc3986);
            }
        } else {
            if ($path[0] == '/') {
                $this->path = $path;
            } elseif ($strictRfc3986) {
                $this->path .= '/../' . $path;
            } else {
                $this->path .= '/' . $path;
            }
            $this->normalizePath();
            $this->addQuery($query, $strictRfc3986);
        }

        $this->fragment = $url->getFragment();

        return $this;
    }
public function combine($url, $strictRfc3986 = false)
    {
        $url = self::factory($url);

        // Use the more absolute URL as the base URL
        if (!$this->isAbsolute() && $url->isAbsolute()) {
            $url = $url->combine($this);
        }

        // Passing a URL with a scheme overrides everything
        if ($buffer = $url->getScheme()) {
            $this->scheme = $buffer;
            $this->host = $url->getHost();
            $this->port = $url->getPort();
            $this->username = $url->getUsername();
            $this->password = $url->getPassword();
            $this->path = $url->getPath();
            $this->query = $url->getQuery();
            $this->fragment = $url->getFragment();
            return $this;
        }

        // Setting a host overrides the entire rest of the URL
        if ($buffer = $url->getHost()) {
            $this->host = $buffer;
            $this->port = $url->getPort();
            $this->username = $url->getUsername();
            $this->password = $url->getPassword();
            $this->path = $url->getPath();
            $this->query = $url->getQuery();
            $this->fragment = $url->getFragment();
            return $this;
        }

        $path = $url->getPath();
        $query = $url->getQuery();

        if (!$path) {
            if (count($query)) {
                $this->addQuery($query, $strictRfc3986);
            }
        } else {
            if ($path[0] == '/') {
                $this->path = $path;
            } elseif ($strictRfc3986) {
                $this->path .= '/../' . $path;
            } else {
                $this->path .= '/' . $path;
            }
            $this->normalizePath();
            $this->addQuery($query, $strictRfc3986);
        }

        $this->fragment = $url->getFragment();

        return $this;
    }
public function combine ( $ url , $ strictRfc3986 = false ) { $ url = self :: factory ( $ url ) ; // Use the more absolute URL as the base URL if ( ! $ this -> isAbsolute ( ) && $ url -> isAbsolute ( ) ) { $ url = $ url -> combine ( $ this ) ; } // Passing a URL with a scheme overrides everything if ( $ buffer = $ url -> getScheme ( ) ) { $ this -> scheme = $ buffer ; $ this -> host = $ url -> getHost ( ) ; $ this -> port = $ url -> getPort ( ) ; $ this -> username = $ url -> getUsername ( ) ; $ this -> password = $ url -> getPassword ( ) ; $ this -> path = $ url -> getPath ( ) ; $ this -> query = $ url -> getQuery ( ) ; $ this -> fragment = $ url -> getFragment ( ) ; return $ this ; } // Setting a host overrides the entire rest of the URL if ( $ buffer = $ url -> getHost ( ) ) { $ this -> host = $ buffer ; $ this -> port = $ url -> getPort ( ) ; $ this -> username = $ url -> getUsername ( ) ; $ this -> password = $ url -> getPassword ( ) ; $ this -> path = $ url -> getPath ( ) ; $ this -> query = $ url -> getQuery ( ) ; $ this -> fragment = $ url -> getFragment ( ) ; return $ this ; } $ path = $ url -> getPath ( ) ; $ query = $ url -> getQuery ( ) ; if ( ! $ path ) { if ( count ( $ query ) ) { $ this -> addQuery ( $ query , $ strictRfc3986 ) ; } } else { if ( $ path [ 0 ] == '/' ) { $ this -> path = $ path ; } elseif ( $ strictRfc3986 ) { $ this -> path .= '/../' . $ path ; } else { $ this -> path .= '/' . $ path ; } $ this -> normalizePath ( ) ; $ this -> addQuery ( $ query , $ strictRfc3986 ) ; } $ this -> fragment = $ url -> getFragment ( ) ; return $ this ; }
Combine the URL with another URL. Follows the rules specific in RFC 3986 section 5.4.

@param string $url           Relative URL to combine with
@param bool   $strictRfc3986 Set to true to use strict RFC 3986 compliance when merging paths. When first
released, Guzzle used an incorrect algorithm for combining relative URL paths. In
order to not break users, we introduced this flag to allow the merging of URLs based
on strict RFC 3986 section 5.4.1. This means that "http://a.com/foo/baz" merged with
"bar" would become "http://a.com/foo/bar". When this value is set to false, it would
become "http://a.com/foo/baz/bar".
@return Url
@throws InvalidArgumentException
@link http://tools.ietf.org/html/rfc3986#section-5.4
Combine the URL with another URL . Follows the rules specific in RFC 3986 section 5 . 4 .