Re: or return problem
| From: | Curt Zirzow | Date: | Wed, 08 Oct 2003 16:00:39 +0000 |
| Subject: | Re: or return problem | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-165467@lists.php.net to get a copy of this message | ||
* Thus wrote Robert Cummings (robert@interjinn.com):
> On Wed, 2003-10-08 at 11:43, Curt Zirzow wrote:
> > * Thus wrote Chris Shiflett (shiflett@php.net):
> > > --- "Ford, Mike [LSS]" <M.Ford@lmu.ac.uk>"
> > > <M.Ford@lmu.ac.uk> wrote:
> > > > Firstly, "or", as a Boolean operator requires two operands, both of
> > > > which must have an actual value.
> > >
> > > [snip]
> > >
> > > > statements don't have a value (and can't even be coerced to have
> > > > one), so "return" can't be valid as one of the operands to
> > > > "or".
> > >
> > > Based on yesterday's discussion, this seems to be a very common misconception.
> > > I will try to clear it up.
> >
> > To add this, the 'include' family also accepts this construct:
> >
> > condition or include(file);
> >
> > Which also violates the rule that statments (constructs) dont have return
> > values.
> >
>
> This isn't a rule per se since it really depends on whether special
> treatment was given to the construct. The internals developers probably
> didn't see a need to provide support for "return" in conditionals since
> it can't return a value to the conditional. Incidentally does return in
> this manner work in perl since it appears that's what the "or die()"
> stuff is attmepting to mimic.
perl:
0 or return;
Works fine.
Curt
--
"My PHP key is worn out"
PHP List stats since 1997:
http://zirzow.dyndns.org/html/mlists/