array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'uri-whatwg-url.withusername.php', 1 => 'Uri\\WhatWg\\Url::withUsername', 2 => 'Modify the username component', ), 'up' => array ( 0 => 'class.uri-whatwg-url.php', 1 => 'Uri\\WhatWg\\Url', ), 'prev' => array ( 0 => 'uri-whatwg-url.withscheme.php', 1 => 'Uri\\WhatWg\\Url::withScheme', ), 'next' => array ( 0 => 'enum.uri-uricomparisonmode.php', 1 => 'Uri\\UriComparisonMode', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/uri/uri/whatwg/url/withusername.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 8 >= 8.5.0)
Uri\WhatWg\Url::withUsername — Modify the username component
Creates a new URL and modifies its username component.
usernameThe modified Uri\WhatWg\Url instance.
If the resulting URL is invalid, a Uri\WhatWg\InvalidUrlException is thrown.
Beispiel #1 Uri\WhatWg\Url::withUsername() basic example
<?php
$url = new \Uri\WhatWg\Url("https://user:password@example.com");
$url = $url->withUsername("usr");
echo $url->getUsername();
?>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:
usr