Home  >  Article  >  Backend Development  >  php判断是否四到11位数字

php判断是否四到11位数字

WBOY
WBOYOriginal
2016-06-13 12:12:001162browse

php判断是否4到11位数字
php判断是否4到11位数字
php判断是否是5到20位数字字母下划线减号
------解决思路----------------------
preg_match('/^\d{4,11}$/', $text)
preg_match('/^[\w-]{5,20}$/', $text)


------解决思路----------------------
preg_match返回1,匹配到了,是正确的,改为:
if(!preg_match('/^\d{4,11}$/', $text)){write_msg("QQ号格式不正确"); }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn