How can the PHP function "parse_url" be used to examine a URL and append the URI scheme if necessary?
When examining a URL using the PHP function "parse_url", it may be necessary to check if the URI scheme is present. If the URI scheme is missing, you can append it to the URL to ensure it is properly formatted. This can be done by checking the "scheme" key returned by "parse_url" and adding it if it is not present.
$url = "example.com/page";
$parsed_url = parse_url($url);
if (!isset($parsed_url['scheme'])) {
$url = 'http://' . $url;
}
echo $url;