Modify the scheme component

# Uri\Rfc3986\Uri::withScheme

(PHP 8 >= 8.5.0)

Uri\Rfc3986\Uri::withScheme — Modify the scheme component

### 说明

public function Uri\Rfc3986\Uri::withScheme(?string `$scheme`): static

Creates a new URI and modifies its scheme component.

### 参数

`scheme`
  New scheme component.

### 返回值

The modified Uri\Rfc3986\Uri instance.

### 错误／异常

If the resulting URI is invalid, a Uri\InvalidUriException is thrown.

### 示例

示例 #1 Uri\Rfc3986\Uri::withScheme() basic example

    <?php
    $uri = new \Uri\Rfc3986\Uri("https://example.com");
    $uri = $uri->withScheme("http");

    echo $uri->getScheme();
    ?>

以上示例会输出：

    http

### 参见

- Uri\Rfc3986\Uri::getRawScheme() - Retrieve the raw scheme component
- Uri\Rfc3986\Uri::getScheme() - Retrieve the normalized scheme component
- Uri\WhatWg\Url::withScheme() - Modify the scheme component

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open