Uri\WhatWg\Url::withScheme
PHP function
Edit on GitHub ✎
(PHP 8 >= 8.5.0)
Modify the scheme component
Description
Uri\WhatWg\Url::withScheme(string $scheme): static
Creates a new URL and modifies its scheme component.
Parameters
schemeNew scheme component.
Return Values
The modified Uri\WhatWg\Url instance.
Errors/Exceptions InvalidUrlException
Examples
Uri\WhatWg\Url::withScheme basic example
php
<?php
$url = new \Uri\WhatWg\Url("https://example.com");
$url = $url->withScheme("http");
echo $url->getScheme();
?>The above example will output:
output
httpSee Also
Uri\WhatWg\Url::getSchemeUri\Rfc3986\Uri::withScheme