|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-09-28 21:14 UTC] tech at sqlsurgeon dot com
Description:
------------
The function returns false if the string is '0'.
Reproduce code:
---------------
---
From manual page: function.ctype-digit#Notes
---
$tripSpace = '0';
if(empty($tripSpace)||!ctype_digit($tripSpace)){
$error = true;
echo "<p>TripSpace is $tripSpace</p>";
$posSpaceClass = "inValidField";
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 21:00:02 2026 UTC |
The problem with your code is not in ctype_digit(), but in your test for empty($tripSpace). '0' evaluates as FALSE; ergo, your test fails, and your if() block executes. If you test ctype_digit('0');, you will find that the result is in fact boolean TRUE.