Uri\WhatWg\Url::parse
(PHP 8 >= 8.5.0)
Parse a URL
Description
Parses a URL.
Parameters
uriA valid URL string to parse (e.g.
/fooor (e.g.https://example.com/foo).baseUrlWhen a String is passed,
uriis applied onbaseUrl, ifuriis a relative-URL string. If either null is passed, oruriis a not a relative-URL string, thenbaseUrldoesn't have any effect.errorsAn Array to pass a list of
Uri\WhatWg\UrlValidationErrorinstances by reference to provide extended information about the errors triggered during parsing.
Return Values
Returns a Uri\WhatWg\Url instance on success, or null on failure.
Examples
Uri\WhatWg\Url::parse basic example
<?php
$url = \Uri\WhatWg\Url::parse("https://example.com");
if ($url !== null) {
echo "Valid URL: " . $url->toAsciiString();
} else {
echo "Invalid URL";
}
?>The above example will output:
Valid URL: https://example.com/See Also
Uri\WhatWg\Url::__constructUri\WhatWg\Url::resolveUri\Rfc3986\Uri::parse