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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.