I'm trying to validate the Twitter URL which my users will submit.
This is what I have:
$twitter = "http://twitter.com/jack";
$parse = parse_url($twitter);
if($parse['host'] !== 'www.twitter.com') {
$error[] = "Invalid Twitter URL.";
}
That doesn't seems to do the job. I don't really want to use regular expressions as the parse_url
seems to be made for this kind of validation.
Anyone knows what's going wrong here?
You are checking for www.twitter.com
but the host in the URL is just twitter.com
, so check for that instead.