graham23s Posted June 27, 2008 Share Posted June 27, 2008 Hi Guys, i was wondering if there was a better way to check a url format than the one i made: <?php // check the url format if (!preg_match("/^http:/", "$var_url")) { $errors[] = "Your URL looks invalid, does it start with http://"; } ?> as you can see its basic lol thanks guys Graham Link to comment https://forums.phpfreaks.com/topic/112175-checking-a-url-format/ Share on other sites More sharing options...
Guest Posted June 27, 2008 Share Posted June 27, 2008 <?php $check = substr($url, 0, 7); if($check != 'http://') { $errors[] = "Your URL looks invalid, does it start with http://"; } ?> Link to comment https://forums.phpfreaks.com/topic/112175-checking-a-url-format/#findComment-575859 Share on other sites More sharing options...
Rowno Posted June 27, 2008 Share Posted June 27, 2008 An easier way would be to use: checkdnsrr($domain, "ANY") if you want to check if a domain exists or not. Link to comment https://forums.phpfreaks.com/topic/112175-checking-a-url-format/#findComment-575878 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.