(PHP 8 >= 8.5.0)
Uri\WhatWg\Url::withPassword — Modify the password component
$password
Creates a new URL and modifies its password component.
password
New password component.
The modified Uri\WhatWg\Url instance.
If the resulting URL is invalid, a Uri\WhatWg\InvalidUrlException is thrown.
Example #1 Uri\WhatWg\Url::withPassword() basic example
<?php $url = new \Uri\WhatWg\Url("https://user:password@example.com"); $url = $url->withPassword("pass"); echo $url->getPassword(); ?>
The above example will output:
pass