update page now

Uri\WhatWg\Url::withFragment

(PHP 8 >= 8.5.0)

Uri\WhatWg\Url::withFragmentModifie le composant fragment

Description

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

Crée une nouvelle URL et modifie son composant fragment.

Liste de paramètres

fragment
Nouveau composant fragment.

Valeurs de retour

L'instance Uri\WhatWg\Url modifiée.

Erreurs / Exceptions

Si l'URL résultante est invalide, une exception Uri\WhatWg\InvalidUrlException est lancée.

Exemples

Exemple #1 Exemple simple avec Uri\WhatWg\Url::withFragment()

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

echo
$url->getFragment();
?>

L'exemple ci-dessus va afficher :

bar

Voir aussi

add a note

User Contributed Notes

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