a value is come from my form and I want to check if it is integer. I'm trying to check with gettype() but it is returning "string". the source of this value is html form. i'm trying to check like this if (gettype($value)== 'integer'){do the task} if i echo gettype($value); it prints "string" and if i echo $value; it prints "45427" it's not being checked as integer although $value prints integer. Where is the problem ? any alternative way with php except javascript?
check following link and you will know it all http://theserverpages.com/php/manual/en/function.is-int.php
You can also use ctype functions... http://php.net/manual/en/function.ctype-digit.php or is numeric, which may be more appropriate for decimal or other formats. http://www.php.net/manual/en/function.is-numeric.php
that's not an integer, it's a string, see the 'number' has quotes around it. if you var_dump($value) you'll see string(5) "45427". You could try using $value = intval($_POST['value']) or however you catch it to enforce integer type, so when you var_dump after that you should see int(5) 45427.
there is a php builtin function called isnumber, it will return true if the string only numbers and false if not..