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 — Chequear posibles caracteres alfanuméricos
- ctype_alpha — Chequear posibles caracteres alfabéticos
- ctype_cntrl — Chequear posibles caracteres de control
- ctype_digit — Chequear posibles caracteres numéricos
- ctype_graph — Chequear posibles caracteres imprimibles, con excepción de los espacios
- ctype_lower — Chequear posibles caracteres en minúscula
- ctype_print — Chequear posibles caracteres imprimibles
- ctype_punct — Chequear posibles caracteres imprimibles que no son ni espacios en blanco ni caracteres alfanuméricos
- ctype_space — Chequear posibles caracteres de espacio en blanco
- ctype_upper — Chequear posibles caracteres en mayúscula
- ctype_xdigit — Chequear posibles caracteres que representen un dígito hexadecimal
Ctype Functions
14-Oct-2006 05:44
avarab at gmail dot com
03-Jan-2006 10:58
03-Jan-2006 10: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
