Reputation: 239
Well.. I want to check if the a url is valid.
So that they can not just enter things like hoadw
, adwij£1%
, but that the inserted url have to be a valid one like domain.com
.
Was thinking of a function like this:
function checkurl($url) {
if ($url = "VALID") {
return true;
}else{
return false;
}
}
Upvotes: 0
Views: 1953
Reputation: 15338
You should use filter_var()
:
function checkurl($url)
//if it's valid it return's the URL else FALSE
return filter_var($url, FILTER_VALIDATE_URL);
}
PS: you must be running PHP 5.2 or later.
Upvotes: 5