php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #41269 ctype_digit returns 1 for an empty string
Submitted: 2007-05-03 16:24 UTC Modified: 2007-05-11 01:00 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: sedat dot capar at isbank dot net dot tr Assigned:
Status: No Feedback Package: Feature/Change Request
PHP Version: 5.2.2 OS: win2003
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sedat dot capar at isbank dot net dot tr
New email:
PHP Version: OS:

 

 [2007-05-03 16:24 UTC] sedat dot capar at isbank dot net dot tr
Description:
------------
ctype_digit returns 1 (TRUE) for an empty string (I do not mean a blank character) however it must return false (NULL) because empty string means there is no digit. 

Reproduce code:
---------------
$number="";
print ctype_digit($number)."*";
$number=" ";
print ctype_digit($number)."*";
$number="1";
print ctype_digit($number);

Expected result:
----------------
**1

Actual result:
--------------
1**1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-03 16:39 UTC] tony2001@php.net
What are you talking about?

# php -r 'var_dump(ctype_digit(""));'
bool(false)
# php -r 'var_dump(ctype_digit(" "));'
bool(false)
# php -r 'var_dump(ctype_digit("1"));'
bool(true)

 [2007-05-03 19:05 UTC] sedat dot capar at isbank dot net dot tr
Hello, 
you must try your code under windows to understand what I mean
here is the results of your codes when I run them under windows


C:\php5>php -r var_dump(ctype_digit('23423'));
bool(true)

C:\php5>php -r var_dump(ctype_digit(''));
bool(true)

C:\php5>php -r var_dump(ctype_digit('sdf345'));
bool(false)

As you see in second one it returned true, however it must return false.
 [2007-05-03 19:46 UTC] tony2001@php.net
What PHP version are you using?
(Somehow I doubt it's really 5.2.2).
 [2007-05-11 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 21:01:30 2024 UTC