(PHP 8 >= 8.5.0)
Uri\Rfc3986\Uri::parse — Parse a URI
$uri
$baseUrl
null
Parses a URI.
uri
URI to parse.
baseUrl
When a string is passed, uri is applied on baseUrl, if uri is a relative reference. If either null is passed, or uri is a not a relative reference, then baseUrl doesn't have any effect.
Returns a Uri\Rfc3986\Uri instance on success, or null on failure.
Example #1 Uri\Rfc3986\Uri::parse() basic example
<?php $uri = \Uri\Rfc3986\Uri::parse("https://example.com"); if ($uri !== null) { echo "Valid URI: " . $uri->toString(); } else { echo "Invalid URI"; }
The above example will output:
Valid URI: https://example.com