当前位置:Gxlcms > PHP教程 > php判断是否4到11位数字

php判断是否4到11位数字

时间:2021-07-01 10:21:17 帮助过:37人阅读

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号格式不正确") }


这样搞报错
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位数字字母下划线减号




搞定了

人气教程排行