php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #42426 ctype_alnum fails on integers
Submitted: 2007-08-25 16:50 UTC Modified: 2007-08-28 10:18 UTC
From: phpbugs dot 20 dot zsh at spamgourmet dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.3 OS: Irrelevant
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: phpbugs dot 20 dot zsh at spamgourmet dot com
New email:
PHP Version: OS:

 

 [2007-08-25 16:50 UTC] phpbugs dot 20 dot zsh at spamgourmet dot com
Description:
------------
ctype_alnum returns false if an integer is passed.

Reproduce code:
---------------
<?php
$var = 42;
var_dump($var, "$var");
?>


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


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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-25 16:55 UTC] phpbugs dot 20 dot zsh at spamgourmet dot com
Oops, the reproduce code should be:

<?php
$var = 42;
var_dump(ctype_alnum($var), ctype_alnum("$var"));
?>
 [2007-08-25 18:22 UTC] bjori@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2007-08-27 08:57 UTC] phpbugs dot 20 dot zsh at spamgourmet dot com
That's expected behavior? Reclassified...
 [2007-08-27 10:13 UTC] pajoye@php.net
ctype_alnum ( string $text )

it takes a string not integer. Please see the manual for further support questions.
 [2007-08-28 09:55 UTC] phpbugs dot 20 dot zsh at spamgourmet dot com
I don't see the problem! PHP is a weak-typed language... what about sleep() for instance?

void sleep ( _int_ $seconds )
<?php
sleep('5');
?>

So why shouldn't ctype_alnum just accept all scalar values as strings?
 [2007-08-28 10:18 UTC] pajoye@php.net
"So why shouldn't ctype_alnum just accept all scalar values as strings?"

As it is a validation function, it has to be strict.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 17:01:33 2025 UTC