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