Re: or return problem
| From: | Robert Cummings | Date: | Tue, 07 Oct 2003 18:51:24 +0000 |
| Subject: | Re: or return problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-165350@lists.php.net to get a copy of this message | ||
On Tue, 2003-10-07 at 14:45, Chris Shiflett wrote:
> --- Robert Cummings <robert@interjinn.com> wrote:
> > > >Directly from the docs:
> > > >
> > > >
> > > > http://ca3.php.net/manual/en/function.return.php
> > > >
> > > >First line:
> > > >
> > > > "If called from within a function, the return() statement
> > > > immediately ends execution of the current function"
> > > >
> > > >Important concept:
> > > >
> > > > IMMEDIATELY returns.
> > > >
> > > >Learn to read.
> > >
> > > What does that have to do with anything?
> >
> > How can you possibly test, in a conditional, the return value of the
> > return statement itself when it has no value to return and even
> > causes the current scope to exit IMMEDIATELY??
>
> The code in question, I believe, was basically this:
>
> function foo()
> {
> true or return('foo');
> }
>
> Your answer does not address the question as to why this is invalid syntax, but
> instead you explain how return works. This is what Leif is questioning, I
> believe.
>
> Regardless, a little less hostility would be nice.
The original post came from someone being lazy, that appears to be
influencing my take on the thread :) Also given the above code, it's
completely pointless since the first operand is true and so it is
impossible for return( 'foo' ) to ever be evaluated (and as stated in a
post just before this the expression shouldn't break). Nonetheless given
a variable as the first operand, I think anyone coding a return in a
conditional like that is asking for trouble since I would guess that it
has an undefined return value.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'