@robert at mediamonks dot com & withheld at withheld dot com:
I personally believe more in solutions than problems. If you're concerned about the possibility of an int type variable being passed to ctype_digit()--and don't want to add another conditional statement using is_int() to avoid the problem--there's another simple solution: typecast it.
<?php
$test_values = array(123,'456','7eight9');
foreach($test_values as $test) {
if(ctype_digit($test)) echo 'True' . "\n";
else echo 'False' . "\n";
}
$test_values = array(123,'456','7eight9');
foreach($test_values as $test) {
if(ctype_digit((string)$test)) echo 'True' . "\n";
else echo 'False' . "\n";
}
?>