Uri\WhatWg\Url::withPassword
PHP function
Edit on GitHub ✎
(PHP 8 >= 8.5.0)
Modify the password component
Description
Uri\WhatWg\Url::withPassword(string|null $password): static
Creates a new URL and modifies its password component.
Parameters
passwordNew password component.
Return Values
The modified Uri\WhatWg\Url instance.
Errors/Exceptions InvalidUrlException
Examples
Uri\WhatWg\Url::withPassword basic example
php
<?php
$url = new \Uri\WhatWg\Url("https://user:password@example.com");
$url = $url->withPassword("pass");
echo $url->getPassword();
?>The above example will output:
output
passSee Also
Uri\WhatWg\Url::getPasswordUri\WhatWg\Url::getUsernameUri\Rfc3986\Uri::withUserInfo