update page now

Uri\WhatWg\Url::withUsername

(PHP 8 >= 8.5.0)

Uri\WhatWg\Url::withUsernameModifie le composant nom d'utilisateur

Description

public Uri\WhatWg\Url::withUsername(?string $username): static

Crée une nouvelle URL et modifie son composant nom d'utilisateur.

Liste de paramètres

username
Nouveau composant nom d'utilisateur.

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

<?php
$url
= new \Uri\WhatWg\Url("https://user:password@example.com");
$url = $url->withUsername("usr");

echo
$url->getUsername();
?>

L'exemple ci-dessus va afficher :

usr

Voir aussi

add a note

User Contributed Notes

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