php8.5
Home/ Manual/ rfc3986 / uri/ Uri\Rfc3986\Uri::resolve

Uri\Rfc3986\Uri::resolve

PHP function Edit on GitHub ✎

(PHP 8 >= 8.5.0)

Resolve a URI with the current object as the base URL

Description

Uri\Rfc3986\Uri::resolve(string $uri): static

Resolves a URI - which may potentially be a relative reference - with the current object as the base URL.

Parameters

uri

A URI to apply on the current object.

Return Values

A new Uri\Rfc3986\Uri instance.

Errors/Exceptions InvalidUriException

Examples

Uri\Rfc3986\Uri::resolve basic example

php
<?php
$uri = new \Uri\Rfc3986\Uri("https://example.com");
$uri = $uri->resolve("/foo");

echo $uri->toRawString();
?>

The above example will output:

output
https://example.com/foo

See Also

  • Uri\Rfc3986\Uri::__construct
  • Uri\Rfc3986\Uri::parse
  • Uri\WhatWg\Url::resolve

Source: reference/uri/uri/rfc3986/uri/resolve.xml · from the official PHP manual (php/doc-en)