Published
9: Native URI Extension (RFC 3986 & WHATWG Parsing)
Parsing and manipulating URLs in legacy PHP relies on parse_url(), which can produce unpredictable results when dealing with complex or non-standard URLs. PHP 8.5 introduces a brand-new native URI extension that provides object-oriented parsing, resolution, and normalization adhering strictly to RFC 3986 and WHATWG standards.
PHP 8.4 Example:
PHP
use Uri\Uri;
$uri = Uri::parse('https://user:pass@example.com:8080/path/to/page?query=1#hash');
echo $uri->getHost(); // Outputs: example.com
echo $uri->getPort(); // Outputs: 8080
echo $uri->getPath(); // Outputs: /path/to/pageThe articles and images featured on this platform were generated with the assistance of AI tools.