|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29226 ctype_digit()'s unpredictable results in CLI
Submitted: 2004-07-17 16:20 UTC Modified: 2004-07-20 03:03 UTC
From: gyozo dot papp at chello dot hu Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 5.0.0 OS: Windows XP SP1
Private report: No CVE-ID:
 [2004-07-17 16:20 UTC] gyozo dot papp at chello dot hu
I've just downloaded PHP5 distribution unpack it into c:\php5 to test if ctype_digit works with agruments of integer type. But I've been presented with some weird results some integer constants were passed the check while other were not. 
The most weird thing was that giving 122113 as an argument to ctype_digit() crashed the CLI.

Reproduce code:
c:\php5>php.exe -r "echo ctype_digit(1) ? 1 : 0;"
c:\php5>php.exe -r "echo ctype_digit(12) ? 1 : 0;"
c:\php5>php.exe -r "echo ctype_digit(123) ? 1 : 0;"
c:\php5>php.exe -r "echo ctype_digit(1234) ? 1 : 0;"
c:\php5>php.exe -r "echo ctype_digit(122) ? 1 : 0;"
c:\php5>php.exe -r "echo ctype_digit(12211) ? 1 : 0;"

This crashed the php.exe
c:\php5>php.exe -r "echo ctype_digit(122113) ? 1 : 0;"

Expected result:
I do not know exactly but at least the results of all tests should be consistent. All the above integer arguments should be failed or passed depending on design or implementation choice.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-17 17:19 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

ctype_digit expects a string. If you want to use a int, you have to cast the value: ctype_digit((string)$val);

However the crash occurs both with php4 and 5 on win but not on linux (HEAD and PHP4_3).

 [2004-07-20 03:03 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Tue Oct 13 07:01:43 2015 UTC