trying to validate the url ( https://www.demo ) using the php, its pass the condition so strange.
I have added the code:
$url = 'https://www.dsdsis';
if (filter_var($url, FILTER_VALIDATE_URL)) {
echo($url ."is a valid URL");
} else {
echo($url ."is not a valid URL");
}
its has to be invalid right?
It meets the criteria for the format of a valid URL. The filter does not actually test to see if the URL actually exists.
If you try your test without the protocol included, http
, you will see that it fails. Add the protocol and any combination will be considered valid.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.