WordPress企业主题定制/开发/优化

PHP一些常用的验证函数

首页 » PHP » PHP一些常用的验证函数

PHP一些常用的验证函数

<?
function is_qq($str){
return
preg_match("/^[1-9]\d{4,8}$/", $str);
}

function is_zip($str){
return
preg_match("/^[1-9]\d{5}$/", $str);
}

function is_idcard($str){
return
preg_match("/^\d{15}(\d{2}[A-Za-z0-9])?$/", $str);
}

function is_chinese($str){
return
ereg("^[".chr(0xa1)."-".chr(0xff)."]+$",$str);
}

function is_english($str){
return
preg_match("/^[A-Za-z]+$/", $str);
}

function is_mobile($str){
return
preg_match("/^((\(\d{3}\))|(\d{3}\-))?13\d{9}$/", $str);
}

function is_phone($str){
return
preg_match("/^((\(\d{3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}$/", $str);
}

?>

分类与标签:

PHP

,

相关项目

  • WordPress外贸企业主题

  • 最近更新

  • 热门标签