Home > Backend Development > PHP Tutorial > php判断是否4到11位数字

php判断是否4到11位数字

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:43:03
Original
1722 people have browsed it

php判断是否4到11位数字
php判断是否是5到20位数字字母下划线减号


回复讨论(解决方案)

preg_match('/^\d{4,11}$/', $text)
preg_match('/^[\w-]{5,20}$/', $text)

preg_match('/^\d{4,11}$/', $text)
preg_match('/^[\w-]{5,20}$/', $text)



if(preg_match('/^\d{4,11}$/', $text)){write_msg("QQ号格式不正确") }
Copy after login


这样搞报错
Parse error: syntax error, unexpected T_EMPTY in 

if(preg_match('/^\d{4,11}$/', $text)){write_msg("QQ号格式不正确"); }
这样不行啊

php判断是否4到11位数字
php判断是否是5到20位数字字母下划线减号

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

第几行报错?你还有其他代码吧。

搞定

if(preg_match('/^\d{4,11}$/', $text)){write_msg("QQ号格式不正确"); }
这样不行啊


php判断是否4到11位数字
php判断是否是5到20位数字字母下划线减号




搞定了
Related labels:
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template