Small additional info about "expression" and "language construct".
Expression is anything that have value.
Therefore, if language construct returns value => valid expression.
Following code works:
($val) ? include('abc.php') : include('def.php');
Following code does NOT work:
($val) ? echo('abc') : echo('def');
both "include" and "echo" is language construct, but "include" returns value.
Thus "include" is valid expression while "echo" is not.
"return" does not return value. (It returns value to caller, but not return
value for expression context)
User defined functions always return value, even if there is no "return"
statement => functions are always valid expression.
Hope this helps.
--
Yasuo Ohgaki
"Jeffrey Paul" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> At 03:56 AM 4/13/2001, Peter Harkins wrote:
> > This generates a parse error:
> > mysql_connect("localhost", "root", "rootpw") or
> > return("bar");
> >
> > But all the following work fine:
> > mysql_connect("localhost", "root", "rootpw") or die("bar");
> >
> > mysql_connect("localhost", "root", "rootpw") or
> > print("bar");
> >
> > if (!mysql_connect("localhost", "root", "rootpw")) {
> > return("bar");
> > }
> >
> > Why? mysql_connect returns false on failure either way... I
> > notice die
>
>
> return isn't a function but a language construct. This is why the third
> working line with the curlybraces works, and without them it doesn't.
>
> include() is a language construct too. the particulars of using language
> constructs (like return() and include()) with control structure syntax are
> explained on the page for include().
>
> http://us2.php.net/manual/en/function.include.php
>
> -j (aka sneak)
>
>
>
> ----------------------------------------------
> [EMAIL PROTECTED] - 0x514DB5CB
> he who lives these words shall not taste death
> becoming nothing yeah yeah
> forever liquid cool
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]