php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #30378 Random results with ctype_digit
Submitted: 2004-10-10 00:15 UTC Modified: 2004-10-11 16:32 UTC
From: guth at fiifo dot u-psud dot fr Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5CVS-2004-10-10 (dev) OS:
Private report: No CVE-ID: None
 [2004-10-10 00:15 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-11 07:56 UTC] 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-11 16:32 UTC] vrana@php.net
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."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 23:01:28 2024 UTC