Re: or return problem

From: Date: Wed, 08 Oct 2003 15:43:45 +0000
Subject: Re: or return problem
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-165461@lists.php.net to get a copy of this message
* 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. I have a feeling die() was special cased to inherit the popular perl method of using: condition or die(); > > 1. If you find some Coke or Pepsi, buy some. > > This suggests that either Coke or Pepsi will suffice. In PHP: > > if ($type == 'coke' || $type == 'pepsi') > { > buy_some(); > } So now we're at $coke or $pepsi and buy_some() :) Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/

« previous php.general (#165461) next »