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

php如何用正则表达式判断连接和时间是否合法。
时间只显示年月日,时间格式为2008-08-08
连接地址的话,要考虑http,https这两种情况吧,或者你有更全的更好。

------解决方案--------------------
$s='2008-08-08';
echo $s == date("Y-m-d",strtotime($s)) ? 'yes' : 'no' ;

网址的话网上搜,太多了。
------解决方案--------------------
$url = "http://www.liuxingyuyuni.cublog.cn";
if(!preg_match('^(http
------解决方案--------------------
https)\:\/\/([a-zA-Z0-9]+\.)?([a-zA-Z0-9]+\.[a-zA-Z0-9]+)+', $url))
{
echo 'wrong';
}
else 
{
echo 'ok';
}