Uri\WhatWg\Url::getUsername
PHP function
Edit on GitHub ✎
(PHP 8 >= 8.5.0)
Retrieve the username component
Description
Uri\WhatWg\Url::getUsername(): string|null
Retrieves the username component.
Parameters Parameters
Return Values
Returns the username component as a String if the username component exists, null is returned otherwise.
Examples
Uri\WhatWg\Url::getUsername basic example
php
<?php
$url = new \Uri\WhatWg\Url("https://username:password@example.com");
echo $url->getUsername();
?>The above example will output:
output
usernameSee Also
Uri\WhatWg\Url::withUsernameUri\Rfc3986\Uri::getRawUsernameUri\Rfc3986\Uri::getUsername