Uri\WhatWg\Url::resolve
(PHP 8 >= 8.5.0)
Uri\WhatWg\Url::resolve — Resolve a URL with the current object as the base URL
Description
Resolves a valid URL string - which may potentially be a relative-URL string - with the current object as the base URL.
Parameters
uri
A valid URL string (e.g. /foo or https://example.com/foo) to apply on
the current object.
softErrors
An array to pass a list of Uri\WhatWg\UrlValidationError instances by reference to provide extended information about the soft errors triggered during reference resolution.
Return Values
A new Uri\WhatWg\Url instance.
Errors/Exceptions
If the resulting URL is invalid, a Uri\WhatWg\InvalidUrlException is thrown.
Examples
Example #1 Uri\WhatWg\Url::resolve() basic example
<?php
$url = new \Uri\WhatWg\Url("https://example.com");
$url = $url->resolve("/foo");
echo $url->toAsciiString();
?>The above example will output:
https://example.com/foo
See Also
- Uri\WhatWg\Url::__construct() - Construct the Url object
- Uri\WhatWg\Url::parse() - Parse a URL
- Uri\Rfc3986\Uri::resolve() - Resolve a URI with the current object as the base URI
来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。
