update page now

Uri\WhatWg\Url::withPath

(PHP 8 >= 8.5.0)

Uri\WhatWg\Url::withPathModifie le composant chemin

Description

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

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

Liste de paramètres

path
Nouveau composant chemin.

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

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

echo
$url->getPath();
?>

L'exemple ci-dessus va afficher :

/baz

Voir aussi

add a note

User Contributed Notes

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