(PHP 8 >= 8.5.0)
Uri\WhatWg\Url::withFragment — Modifica o componente fragment
Cria uma nova URL e modifica seu componente fragment.
fragmentA instância de Uri\WhatWg\Url modificada.
Se o URL resultante for inválido, é lançada uma Uri\WhatWg\InvalidUrlException.
Exemplo #1 Exemplo básico de Uri\WhatWg\Url::withFragment()
<?php
$url = new \Uri\WhatWg\Url("https://example.com/#foo");
$url = $url->withFragment("bar");
echo $url->getFragment();
?>O exemplo acima produzirá:
bar