#30378 [Opn->Csd]: Random results with ctype_digit
| From: | vrana@php.net | Date: | Mon, 11 Oct 2004 14:32:24 +0000 |
| Subject: | #30378 [Opn->Csd]: Random results with ctype_digit | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969364491@lists.php.net to get a copy of this message | ||
ID: 30378
Updated by: vrana@php.net
Reported By: guth at fiifo dot u-psud dot fr
-Status: Open
+Status: Closed
Bug Type: Documentation problem
PHP Version: 5CVS-2004-10-10 (dev)
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
"... behave exactly like their C counterparts from ctype.h. It means
that if you pass an integer smaller than 256 it will use the ASCII
value of it to see if it fits in the specified range (digits are in
0x30-0x39). If the number is between -128 (inclusive) and 0 then 256
will be added and the check will be done on that."
Previous Comments:
------------------------------------------------------------------------
[2004-10-11 07:56:30] derick@php.net
This is correct behavior though, as the numbers are automatically
converted to strings in PHP, that's why it is called a losely-typed
language. Though the manual should mention that if you pass an integer
smaller than 256 it will use the ascii value of it to see if it fits in
the specified range (digits are in 0x30-0x39). If the number is between
-128 (inclusive) and 0 then 256 will be added and the check will be
done on that again.
------------------------------------------------------------------------
[2004-10-10 00:15:45] guth at fiifo dot u-psud dot fr
Description:
------------
See the following code :
Reproduce code:
---------------
echo "<?php var_dump(ctype_digit(1)) ?>" | php
echo "<?php var_dump(ctype_digit(1000000000)) ?>" | php
Expected result:
----------------
The prototype of this function is bool ctype_digit ( string text), so i
expected :
bool(false)
bool(false)
Actual result:
--------------
bool(false)
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30378&edit=1