Re: switch, equality and preg_match
| From: | Brian Moon | Date: | Tue, 03 Jul 2001 13:35:29 +0000 |
| Subject: | Re: switch, equality and preg_match | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-58798@lists.php.net to get a copy of this message | ||
If you look back to the original problem, switch was matching the 0 returned
from preg_match to a string. However, if the return value is a boolean it
would not match 0 to a string. However, I guess it would then match the
true to a string.
Brian Moon
------------------------------------------
dealnews.com, Inc.
Makers of dealnews & dealmac
http://dealnews.com/ | http://dealmac.com/
----- Original Message -----
From: "Jon Parise" <jon@csh.rit.edu>
To: "Brian Moon" <brianm@dealnews.com>
Cc: "Andrei Zmievski" <andrei@ispi.net>; <php-dev@lists.php.net>
Sent: Monday, July 02, 2001 7:21 PM
Subject: Re: [PHP-DEV] switch, equality and preg_match
> On Mon, Jul 02, 2001 at 05:01:43PM -0500, Brian Moon wrote:
>
> > IMO, I like preg_match to return a bool and preg_match_all return a
count.
> > But that is me. It may be thought of as inconsistent to some. I just
see
> > the functions has having a different purpose.
>
> That would make sense. preg_match_all() would return 1 if only
> one match is found, so there's no need for preg_match() to return
> the number of matches.
>
> However, even if preg_match() were to return a one or zero, it
> would still function the same in boolean evaluations. That makes
> the whole thing simply a matter of "correctness". Returning an
> 'int' would be more consistent but returning a boolean would be
> specific.
>
> --
> Jon Parise (jon@csh.rit.edu) . Rochester Inst. of Technology
> http://www.csh.rit.edu/~jon/ : Computer Science House Member
>
>