Clean up URL with parse_url
Clean up URL.s with parse_url() by:
* add "http://" if scheme is missing
* add correct "glue" (://) between scheme and host
<?php
$parse = parse_url($url);
if (empty($parse['scheme'])) {
$url = "http://".$url;
}else{
$url = $parse['scheme']."://".$parse['host'].$parse['path']. (!empty($parse['query']) ? "?".$parse['query'] : "") . (!empty($parse['fragment']) ? "#".$parse['fragment'] : "");
}
?>
Knowledge keywords: