In PHP versions before 4.4.1, ctype functions have a bug handling very large integers.
http://bugs.php.net/bug.php?id=34645
See Crimson's comment under ctype_digit, or this test code from the bug:
<?php
$id = 394829384;
var_dump($id);
ctype_digit($id);
var_dump($id);
?>
Expected result:
----------------
int(394829384)
int(394829384)
Actual result:
--------------
int(394829384)
NULL
The fix is to cast it as a string:
<?php
ctype_digit((string)$id);
?>
... or use a current version of PHP!
Ctype Functions
Table of Contents
- ctype_alnum — Check for alphanumeric character(s)
- ctype_alpha — Check for alphabetic character(s)
- ctype_cntrl — Check for control character(s)
- ctype_digit — Check for numeric character(s)
- ctype_graph — Check for any printable character(s) except space
- ctype_lower — Check for lowercase character(s)
- ctype_print — Check for printable character(s)
- ctype_punct — Check for any printable character which is not whitespace or an alphanumeric character
- ctype_space — Check for whitespace character(s)
- ctype_upper — Check for uppercase character(s)
- ctype_xdigit — Check for character(s) representing a hexadecimal digit
Ctype Functions
14-Oct-2006 04:44
avarab at gmail dot com
03-Jan-2006 09:58
03-Jan-2006 09:58
In case the ctype_*() functions aren't compiled in your PHP and you can't recompile for some reason (e.g. shared host) you can use the compatability functions from the MediaWiki project which use preg_* as a replacement[1], removing lines 2 and 3 in the source should make them suitable for usage elsewhere.
Shameless self-advertisement, but hey, we find them useful;)
1. A tinyurl because the submission script complained about long lines: http://tinyurl.com/7hz4l
1. The real url split up:
http://cvs.sourceforge.net/viewcvs.py/*checkout*/
wikipedia/phase3/includes/compatability/ctype.php
