note 110747 deleted from function.ctype-digit by danbrown

From: Date: Fri, 30 Nov 2012 18:46:46 +0000
Subject: note 110747 deleted from function.ctype-digit by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192237@lists.php.net to get a copy of this message
Note Submitter: Joni ---- A simple fix to make sure that integers are always treated as strings - to avoid unexpected results. Just add double quotes around your variable. <?php ctype_digit(5); // false ctype_digit(48); // true ctype_digit(255); // false ctype_digit(256); // true ctype_digit("5"); // true ctype_digit("48"); // true ctype_digit("255"); // true ctype_digit("256"); // true $integer = 5; ctype_digit($integer); // false ctype_digit("$integer"); // true ! ?>

« previous php.notes (#192237) next »