php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #42007 ctype_alnum( int ) will return false
Submitted: 2007-07-16 10:54 UTC Modified: 2007-08-16 12:09 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: adrian dot gheorghe at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.3 OS: Windows XP Sp2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: adrian dot gheorghe at gmail dot com
New email:
PHP Version: OS:

 

 [2007-07-16 10:54 UTC] adrian dot gheorghe at gmail dot com
Description:
------------
ctype_alnum returns false if you pass it an integer (ie 7). I know the docs say that it should receive a string, as all ctype_* functions should, but I believe it's pointless to have to do a ctype_alnum( '' . $var ) at every call just to be sure. Also, the docs say that the function is equivalent to preg_match('/^[a-z0-9]+$/iD', $text) and matching 7 against that expression will work.

Reproduce code:
---------------
var_dump( ctype_alnum( 7 ) );

Expected result:
----------------
bool(true)

Actual result:
--------------
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-16 18:19 UTC] jani@php.net
Documentation shouldn't say it's equivalent to regex matching when it really isn't..docs need update, the function is fine as is.
 [2007-08-16 12:09 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.

According to beginning of CType chapter, small numbers are compared differently. Equivalent part removed.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Aug 14 06:00:03 2025 UTC