I am validating URL by FILTER_VALIDATE_URL
function.
$url_1 = "http://example.com";
$url_2 = "http://http://example.com";
if (filter_var($url_1, FILTER_VALIDATE_URL)) {
echo "URL is valid";
}
else {
echo "URL is invalid";
}
It's giving me valid URL message in $url_1
and $url_2
. It shouldn't be like that. second URL is not valid.
What's the correct way to solve this issue?
Thanks.