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