How to form a valid http url if not exists it in given url?
by barkkathulla[ Edit ] 2014-05-31 11:06:36
Create a valid http:// url if not exists it in given url
function checkurl($input_url) {
if (!preg_match("~^(?:f|ht)tps?://~i", $input_url)) {
$input_url = "http://" . $input_url;
}
return $input_url;
}
$filtered_url = parse_url($input_url);
its very useful while getting valid image by input url.
If we miss http:// it will not upload valid image.
So before that this validation is necessary to create a valid image.