1. 判断Email:
<?php
function is_email ( $email ){
return strlen ( $email ) > 6 && preg_match ( “ /^[\w\-\.]+@[\w\-]+(\.\w+)+$/ “ , $email ) ;
}
?>
function is_email ( $email ){
return strlen ( $email ) > 6 && preg_match ( “ /^[\w\-\.]+@[\w\-]+(\.\w+)+$/ “ , $email ) ;
}
?>
2. 判断Url:
function
is_url
(
$str
){
return preg_match ( “ /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\] \’ :+!]*([^<> \" ])*$/ “ , $str ) ;
}
return preg_match ( “ /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\] \’ :+!]*([^<> \" ])*$/ “ , $str ) ;
}
3. 判断手机号码:
function
is_mobile
(
$str
){
return preg_match ( “ /^((\(\d{3}\))|(\d{3}\-))?13\d{9}$/ “ , $str ) ;
}
return preg_match ( “ /^((\(\d{3}\))|(\d{3}\-))?13\d{9}$/ “ , $str ) ;
}