resolveRelativeURI example

/** * If the $url is a relative URL, will attempt to create * a full URL by prepending $this->baseURI to it. */
    protected function prepareURL(string $url): string
    {
        // If it's a full URI, then we have nothing to do here...         if (strpos($url, '://') !== false) {
            return $url;
        }

        $uri = $this->baseURI->resolveRelativeURI($url);

        // Create the string instead of casting to prevent baseURL muddling         return URI::createURIString(
            $uri->getScheme(),
            $uri->getAuthority(),
            $uri->getPath(),
            $uri->getQuery(),
            $uri->getFragment()
        );
    }

    
Home | Imprint | This part of the site doesn't use cookies.