update page now

Uri\WhatWg\Url::withHost

(PHP 8 >= 8.5.0)

Uri\WhatWg\Url::withHostModifica el componente de host

Descripción

public Uri\WhatWg\Url::withHost(?string $host): static

Crea una nueva URL y modifica su componente de host.

Parámetros

host
Nuevo componente de host.

Valores devueltos

La instancia de Uri\WhatWg\Url modificada.

Errores/Excepciones

Si la URL resultante es inválida, se lanza una excepción Uri\WhatWg\InvalidUrlException.

Ejemplos

Ejemplo #1 Ejemplo básico de Uri\WhatWg\Url::withHost()

<?php
$url
= new \Uri\WhatWg\Url("https://example.com");
$url = $url->withHost("example.net");

echo
$url->getAsciiHost();
?>

El ejemplo anterior mostrará:

example.net

Ver también

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top