Are there built-in PHP functions that can handle the conversion of relative URLs to absolute URLs?

When working with URLs in PHP, sometimes it's necessary to convert relative URLs to absolute URLs. This can be achieved by using built-in PHP functions like `parse_url` to extract the components of the base URL and the relative URL, and then combining them to form the absolute URL.

function convertRelativeToAbsolute($baseUrl, $relativeUrl) {
    $baseParts = parse_url($baseUrl);
    $relativeParts = parse_url($relativeUrl);

    $scheme = isset($relativeParts['scheme']) ? $relativeParts['scheme'] : $baseParts['scheme'];
    $host = isset($relativeParts['host']) ? $relativeParts['host'] : $baseParts['host'];
    $path = isset($relativeParts['path']) ? $relativeParts['path'] : '';

    return $scheme . '://' . $host . $path;
}

$baseUrl = 'https://www.example.com';
$relativeUrl = '/about';
$absoluteUrl = convertRelativeToAbsolute($baseUrl, $relativeUrl);

echo $absoluteUrl; // Output: https://www.example.com/about