This question already has an answer here:
- Checking if a variable is an integer in PHP 13 answers
I've used either function for checking and validating integers in many applications like so
$foo = $bar;
if (filter_var($foo,FILTER_VALIDATE_INT)) {
// do something
}
AND
if (is_int($foo)) {
// do something
}
Both works perfectly but I want to know the difference between the two in terms of speed and results because PHP being a tricky language has differences between functions that seem to do the same thing e.g mt_rand and rand
Aucun commentaire:
Enregistrer un commentaire