How does PHP Verify that the URL is correct?

Source: Internet
Author: User
How does PHP Verify that the URL is correct??
The URL format is:
Http://www.abc.com
http://ABC.com
http://www.abc.com/
http://ABC.com
http://www.abc.com/s/

http://www.abc.com/s/s/

Http://www.abc.com/s/xx.htm

http://www.abc.com/s/xx.php

http://www.abc.com/s/xx.asp/

Https://www.abc.com/s/xx

ftp://www.abc.com/

Wait a minute

if (Preg_match ("/????????????????? ", $url)) {//How to write here? Able to deal with various possible URL formats?
echo "URL is correct";
}else{
echo "URL error";
}




------Solution--------------------
Contains com|cn|net front dot, followed by/or empty to determine the URL
------Solution--------------------
discuss

I know how to use the regular, the key is how to write, but also to take into account all the above-mentioned format

------Solution--------------------
Then refer to this article Http://www.pin 5i.com/showtopic-25932.html

It's not PHP, but it should be about the same.

------Solution--------------------
What's wrong with CSDN?!

Posted on the URL is not allowed to send, prompted that "your reply body has illegal words or phrases!" ”。

I had to insert a space in the middle. What the hell is this? What's wrong with that website?



――――――――――――――――――――――――――――――――
Based on the plugin extension function provided by CSDN forum, I have made a signature file tool to share with you, welcome technical exchange:)
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.