日期:2014-05-17  浏览次数:20539 次

怎么验证网址是否正确?
网址格式有:
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/

等等

if (preg_match("/?????????????????//",$url)){//这里怎么写?能够应对各种可能的网址格式?
echo "网址正确";
}else{
echo "网址错误";
}




------解决方案--------------------
"/(http:\/\/)?w{3}\.[^/.]+\.(com|net|cn|org).(cn)?/i"
------解决方案--------------------
/^[a-zA-Z]+:\/\/.+/i