ctype second opinions
| From: | Brent Cook | Date: | Fri, 19 Jul 2002 13:41:53 +0000 |
| Subject: | ctype second opinions | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-7782@lists.php.net to get a copy of this message | ||
Dear all,
I would like your opinion, please. I'm currently arguing a bug in the
PHP database, http://bugs.php.net/bug.php?id=18428, and basically
feel
that I have made the correct choice, while the PHP developer feels
otherwise.
The ctype functions in PHP currently return TRUE on an empty string. For
instance, ctype_alpha('a') == TRUE, ctype_alpha('1') == FALSE,
ctype_alpha('') == TRUE. I argued that since no characters in an empty
string match the criteria, an empty string should return FALSE. The
developer argued that "in an empty string every of the 0 charactetrs
matches the (criteria)", so it should return TRUE.
I guess this is all semantics, but it also means that my lexer in DBA
(DBA/Sql_lex.php) has to use if (strlen($c) && ctype_alpha($c)) everytime
it uses a ctype function, since end-of-input can be reached at any time.
I've included compatibility versions of the ctype functions in
DBA/ctype.php since ctype is a relatively new extension and not included
by default until PHP 4.2, but they return false on an empty string (they
actually operate on a single character, like the real ctype functions).
What should I do? Do I have a case or should I concede?
- Brent