I want to check if ID is an integer. It works if I do it that way : if (preg_match("/[0-9]+$/", $_GET['id'])) { // do something... }
But howcome it ain't working with : if (is_int($_GET['id'])) { // do something... }
does it mean that value from $_GET are always set to same type (I suppose it's string type)?
is_int does only check if the var type is an integer:
example:
$var1 = 1; $var2 = "2"; if(is_int($var1)) { echo "var1 is"; } if(is_int($var2)) { echo "var2 is"; }
this will only echo var 1 is
better is if you use is_numeric