(PHP 8 >= 8.5.0)
Uri\Rfc3986\Uri::withHost — Modify the host component
$host
Creates a new URI and modifies its host component.
host
New host component.
The modified Uri\Rfc3986\Uri instance.
If the resulting URI is invalid, a Uri\InvalidUriException is thrown.
Example #1 Uri\Rfc3986\Uri::withHost() basic example
<?php $uri = new \Uri\Rfc3986\Uri("https://example.com"); $uri = $uri->withHost("example.net"); echo $uri->getHost(); ?>
The above example will output:
example.net