Hello Php People,
Which one you favour and why that over others ?
if(filter_var("https://www.sitepoint.com", FILTER_VALIDATE_URL) !== false) {
// it's good url
}
If you want to test if it’s not valid, then:
if(filter_var("https://www.sitepoint.com", FILTER_VALIDATE_URL) === false) {
// it's bad url
}
Is this following statement true or not on this subject ?
“Using the type-explicit ===
and !==
comparison operators avoids treating empty strings or something like “0” as being false.” ?
https://www.php.net/filter_var
I usually do it like following and so they not ok ?
if(!filter_var("https://www.sitepoint.com", FILTER_VALIDATE_URL)) {
// it's bad url
}
if(filter_var("https://www.sitepoint", FILTER_VALIDATE_URL)) {
// it's good url
}
They not best than the previous two ? Yes or no ? I’d like to know. From you.
Let’s see how you code it.
Thank you in advance for your upcoming feed backs.