Valid URL or not?

Posted in Help the coder! on Aug 22, 2009 at 09:04 IST (over 4 years ago). Subscribe to this post Bookmark and Share Email
Showing comments 1 to 4 of total 4 on page 1 of 1
Post reply
« Previous1Next »

rhitwick
Rank: 305
Hello friends,
How can i know whether the given string is a valid URL or not? That is, if i enter www.aaaaaaaaaaaaaabbbbb.com, my program should be able to identify that its not a real address, though it looks valid. And if i enter www.google.com, it should identify it as a real one.

I need to do this using PHP. Any idea?
Posted by rhitwick on Saturday, August 22, 2009, 9:04 am
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

calvin
Rank: 60
I've heard that regular expressions help one in validating string patterns. I dont know how it works though.

http://www.regular-expressions.info/php.html

Perhaps that could offer you some help!
Posted by calvin on Saturday, August 22, 2009, 7:03 pm
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

robinalex
Rank: 1

Install http extension, refer following links for more information:
http://usphp.com/manual/en/book.http.php
http://pecl.php.net/package/pecl_http

Now, you can make an http request for the URL and see that page really exists.

Posted by robinalex on Sunday, August 23, 2009, 8:45 am
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

tsanand129
Rank: 23
Hi
This should do the trick

if(checkdnsrr($hostname))
{
echo "valid";
}
else
{
echo "in valid";
}
Thankful users: rhitwick
Posted by tsanand129 on Sunday, August 23, 2009, 11:01 pm
  • Currently 5.00/5

2 votes

Thank this userFlag this comment
Pages: « Previous1Next »

Post your comment (No registration required)

  Add my comment  

TechieDesi Community

Not signed in (Sign-in or Register)
Be a true TechieDesi!
Top 10 Users
Spread the word
Invite your friends
Fan stuff
Help us improve
Need Help
FAQ's
Search tips
Found a bug? Report!
Feeds and letters
Subscribe via RSS
Archives
Subscribe to newsletter
Unsubscribe e-mail
Miscellaneous
Privacy policy
Visit rootnerve
About us
About us
Support the development
Official Blog
Advertise with us
Careers
Copyright (c) 2008, TechieDesi.com. All rights reserved | About us | Do-Not-Disturb registry | Powered by rootnerve | Page rendered in 0.014 seconds