我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

PHP Regex仅允许具有特定长度的数字

I am trying to create a preg_match test to allow numbers only. Definitely cannot use is_numeric or any variants.

Is this as safe as I can get?

/^\d*$/

And additionally, how would I set a min max range, for example check the number is between 6 and 10 digits?

Well yeah, that's pretty safe. The regex does exactly that... allow only digits.

To specify a certain amount, here is the syntax:

/^\d{6,10}$/

However, since this is a very basic problem, you should probably check out this site.

近期文章

  • php图片上传没有创建缩略图
  • PHP上传具有不同文件名但公共文件夹的多个文件
  • java脚本数组通过ajax(jquery)和json到php
  • 如何在html / css / js / php中更改活动菜单项样式
  • 无法在mysql_fetch_array中获取循环以在单独的行上打印
  • 通过PHP下载文件[关闭]
  • SQL SELECT和GROUP BY Month在9个月以上没有返回任何结果
  • 在Symfony和Doctrine网站上编码荧光笔
  • PHP表单处理
  • PHPMailer不发送邮件
  • Node vs nginx + php-fpm用于数据库驱动的网站
  • CakePHP:选择拥有1个或更多帖子的用户
  • 文件上传和下载超时
  • Codeigniter - 类__PHP_Incomplete_Class的对象无法转换为字符串
  • 在Symfony 1.4中读取CSV
  • ASP是否允许您从PHP等脚本标签中逃脱?
  • DOMDocument中节点的绝对引用供以后使用?
  • termux安装kali遇到了proot报错!!
  • 在浏览器中自动保存PDF
  • 使用Zend_Filter_Input验证日期

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华