update page now

Uri\WhatWg\Url::withFragment

(PHP 8 >= 8.5.0)

Uri\WhatWg\Url::withFragmentModifica el componente de fragmento

Descripción

public Uri\WhatWg\Url::withFragment(?string $fragment): static

Crea una nueva URL y modifica su componente de fragmento.

Parámetros

fragment
Nuevo componente de fragmento.

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

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

echo
$url->getFragment();
?>

El ejemplo anterior mostrará:

bar

Ver también

add a note

User Contributed Notes

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