If you’re ever in need of a regular expression that will validate every domain name to make sure what the user gave you is valid, you can use Shaun Inman’s Regex. I have to admit, while it’s pretty uber, it’s probably easier just to use cURL to see if the URL is valid.
To accomplish website validation using cURL, there is a snippet of code available on the official PHP homepage: http://ca3.php.net/manual/en/function.curl-exec.php#77167. If the HTTP status is 200 after requesting the website using cURL, the website is valid. If not, you can return an error to the user to verify their URL.
One thought on “Validating Domain Names and Websites”
anybody here know of a good site to find more info on php exec? I’ve got this site bookmarked and im gonna keep checking it out, but i still would like to find a site that covers php exec a little more thoroughly..thanks
Comments are closed.