public function getUrlForPath($path)
    {
        $fragments = parse_url($path);

        if (!isset($fragments['path']))
            throw new UrlException("URL is not a valid path: '$path'");

        $newUrl = clone $this;
        $newUrl->_fragments['path'] = $fragments['path'];

        // overwrite RHS components
        foreach (array('query', 'fragment') as $component) {
            if (isset($fragments[$component]))
                $newUrl->_fragments[$component] = $fragments[$component];
            elseif (isset($newUrl->_fragments[$component]))
                unset($newUrl->_fragments[$component]);
        }

        // store the new URL internally
        $newUrl->_inputString = $newUrl->__toString();

        return $newUrl;
    }
public function getUrlForPath($path)
    {
        $fragments = parse_url($path);

        if (!isset($fragments['path']))
            throw new UrlException("URL is not a valid path: '$path'");

        $newUrl = clone $this;
        $newUrl->_fragments['path'] = $fragments['path'];

        // overwrite RHS components
        foreach (array('query', 'fragment') as $component) {
            if (isset($fragments[$component]))
                $newUrl->_fragments[$component] = $fragments[$component];
            elseif (isset($newUrl->_fragments[$component]))
                unset($newUrl->_fragments[$component]);
        }

        // store the new URL internally
        $newUrl->_inputString = $newUrl->__toString();

        return $newUrl;
    }
public function getUrlForPath ( $ path ) { $ fragments = parse_url ( $ path ) ; if ( ! isset ( $ fragments [ 'path' ] ) ) throw new UrlException ( "URL is not a valid path: '$path'" ) ; $ newUrl = clone $ this ; $ newUrl -> _fragments [ 'path' ] = $ fragments [ 'path' ] ; // overwrite RHS components foreach ( array ( 'query' , 'fragment' ) as $ component ) { if ( isset ( $ fragments [ $ component ] ) ) $ newUrl -> _fragments [ $ component ] = $ fragments [ $ component ] ; elseif ( isset ( $ newUrl -> _fragments [ $ component ] ) ) unset ( $ newUrl -> _fragments [ $ component ] ) ; } // store the new URL internally $ newUrl -> _inputString = $ newUrl -> __toString ( ) ; return $ newUrl ; }
Builds a URL with a different path component
@return Url
Builds a URL with a different path component