php.net |  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: None
 [2004-07-17 16:20 UTC] gyozo dot papp at chello dot hu
Description:
------------
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;"
0
c:\php5>php.exe -r "echo ctype_digit(12) ? 1 : 0;"
0
c:\php5>php.exe -r "echo ctype_digit(123) ? 1 : 0;"
0
c:\php5>php.exe -r "echo ctype_digit(1234) ? 1 : 0;"
0
c:\php5>php.exe -r "echo ctype_digit(122) ? 1 : 0;"
0
c:\php5>php.exe -r "echo ctype_digit(12211) ? 1 : 0;"
1

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.


Patches

Pull Requests

History

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

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).

--Pierre
 [2004-07-20 03:03 UTC] iliaa@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC