php - Check if a variable is a natural number -


i want make bid system on website. means users can post bid (natural number). want make sure users don't try post characters, decimal numbers, etc. don't want use is_numeric function because hexadecimal notation allowed. thinking use preg_match this. in php.net documentation function little , have no idea how use preg_match.

so how should check if variable natural number preg_match?

if don't require decimal points: ctype_digit or filter_var($var, filter_validate_int).
if do: filter_var($var, filter_validate_float).


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -