PHP: Is_numeric returns false on 0 [closed] PHP: Is_numeric returns false on 0 [closed] php php

PHP: Is_numeric returns false on 0 [closed]


It is returning true for me in both cases:

var_dump(is_numeric(0));var_dump(is_int(0));

Result:

bool(true)bool(true)


Zero, as an integer is empty.So ensure that there is no check for empty before you check for Is_numeric() or is_int()


var_dump(is_int("0"));

Will pass false because you are passing it the zero as a string literal. You could try passing the same thing as a variable which has gone through (I believe) parseInt("");

Though my php may be a little off, having been Javascripting nonstop the last week or two.