update page now

Uri\WhatWg\Url::withScheme

(PHP 8 >= 8.5.0)

Uri\WhatWg\Url::withSchemeModifie le composant schéma

Description

public Uri\WhatWg\Url::withScheme(string $scheme): static

Crée une nouvelle URL et modifie son composant schéma.

Liste de paramètres

scheme
Nouveau composant schéma.

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

<?php
$url
= new \Uri\WhatWg\Url("https://example.com");
$url = $url->withScheme("http");

echo
$url->getScheme();
?>

L'exemple ci-dessus va afficher :

http

Voir aussi

add a note

User Contributed Notes

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