This is an archive of my old website, kept as a snapshot of that time.

[Tiny Tip] Use is_numeric() instead of is_int() when you have a number as a string

If you have a number as a string is_int() won’t work. This will most probably clear your doubt.

<?php
var_dump(is_int(12));
var_dump(is_int("12"));
?>

Output:

bool(true)
bool(false)


<?php
var_dump(is_numeric(56));
var_dump(is_numeric("56"));
?>

Output:

bool(true)
bool(true)

Happy Programming,

Comments