Why does IPv6 require brackets when specifying the address?

IPv6 addresses contain colons, which are also used to separate the IPv6 address from the port number in URLs. To avoid confusion, IPv6 addresses must be enclosed in brackets when specifying them in URLs or other contexts where colons are used for different purposes. This helps to clearly differentiate the IPv6 address from the port number or other information.

$ipv6Address = '2001:0db8:85a3:0000:0000:8a2e:0370:7334';
$url = "http://[$ipv6Address]/";
echo $url;