update page now

Uri\WhatWg\Url::withPath

(PHP 8 >= 8.5.0)

Uri\WhatWg\Url::withPathModifica el componente de ruta

Descripción

public Uri\WhatWg\Url::withPath(string $path): static

Crea una nueva URL y modifica su componente de ruta.

Parámetros

path
Nuevo componente de ruta.

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::withPath()

<?php
$url
= new \Uri\WhatWg\Url("https://example.com/foo/bar");
$url = $url->withPath("/baz");

echo
$url->getPath();
?>

El ejemplo anterior mostrará:

/baz

Ver también

add a note

User Contributed Notes

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