(PHP 8 >= 8.5.0)
Uri\WhatWg\Url::parse — Parse a URL
$uri, ?Uri\WhatWg\Url $baseUrl = null, array &$errors = null): ?staticParses a URL.
uri/foo or (e.g. https://example.com/foo).
baseUrluri is applied on
baseUrl, if uri is a relative-URL string.
If either null is passed, or uri is a not a relative-URL string, then
baseUrl doesn't have any effect.
errors
Returns a Uri\WhatWg\Url instance on success, or null on failure.
Пример #1 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"
}
?>Результат выполнения приведённого примера:
Valid URL: https://example.com