php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #49703 The function returns false if the string is '0'
Submitted: 2009-09-28 21:14 UTC Modified: 2009-09-29 06:55 UTC
From: tech at sqlsurgeon dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.3.0 OS: Redhad
Private report: No CVE-ID: None
 [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";
			}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-29 06:55 UTC] torben@php.net
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.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 12:00:02 2026 UTC