Re: ctype second opinions

From: Date: Fri, 19 Jul 2002 13:57:16 +0000
Subject: Re: ctype second opinions
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-7783@lists.php.net to get a copy of this message
On Fri, 19 Jul 2002 08:41:53 -0500 (CDT) Brent Cook <busterb@mail.utexas.edu> wrote: > 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. afaik, ctype_alpha checks only the type, returning true if the param is an alhatype. An empty string is an alpha. That s a fact. > if (strlen($c) && ctype_alpha($c)) can be replaced by : if ( ctype_alpha($c) && strlen($c) ) You can check the string length only if $c is a string. hth pa

« previous php.pear.dev (#7783) next »