update page now

Uri\WhatWg\Url::withQuery

(PHP 8 >= 8.5.0)

Uri\WhatWg\Url::withQueryModifie le composant requête

Description

public Uri\WhatWg\Url::withQuery(?string $query): static

Crée une nouvelle URL et modifie son composant requête.

Liste de paramètres

query
Nouveau composant requête.

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

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

echo
$url->getQuery();
?>

L'exemple ci-dessus va afficher :

foo=baz

Voir aussi

add a note

User Contributed Notes

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