[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,


So lazy that he can't even fill this column out.

© 2011 Suhas Tech. All rights reserved.
Proudly powered by Wordpress.