basically it's to do with "lazy evaluation" or whatever it's called....

* logical expressions are read from left to right.
* with OR, the expression reading is halted when the first TRUE is found
* with AND, the expression reading is halted when the first FALSE is found

so with :
 if (true||false)
php will stop processing when it comes across the "true"

and with :
  if (false&&true)
php will stop processing when is comes across the "false"

in both cases, this means that whatever the second expression is, it wont
get "executed"

hope that explains it a bit furthur

Martin

-----Original Message-----
From: jv [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 29, 2002 2:26 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Help with Logical 'OR'


Thanks Matt, Jeff, and Sam
(BTW Sam, for some reason your post didn't come to me on the list through
regular email- I found it when I did a search in the archives at php.net. I
'm pretty sureI didn't delete it. I mention this because I'm sure the list
server hiccups sometimes and I'd hate to offend someone by not thanking or
acknowledging  them :-)  Also,  the truth tables are helpfull in visualizing
the different logical conditions- thanks!)

Anyway,  I've tried all combinations yet still can't get (true||fale) or
(true&&false) to work, even by using (!empty) or (!isset).

I recall reading something about that if a cetrtain envioronmental variable
isn't set to 'on' on the server then... I'm not sure what I'm talking about
so I'll try to look it up again.

I know that I could just nest functions but I'm trying to learn
alternatives...




> At 02:04 PM 1/28/2002 -0600, jv wrote:
> >It seems that only the first condition is being evaluated.
> >
> >I know that if  both of the following conditions are false then the
second
> >set of statements should get read, and that's what happens, but when I
set
> >$name to true and $text to false (true||false) then the first set gets
read.
> >
> >Shouldn't both conditions be true in order for the first set of
statements
> >be read? Why would the first set of statements get read when the
conditions
> >are (true||false)?
> >
> >Thanks in advance for your help.
> >james
> >
> >********************************************************************
> >if ($name || $text)
> >
> >     {
> >
> >   $text = stripslashes("$text");
> >   print "Hello $name\n<br>";
> >   print "You said:\n<br> $text\n";
> >
> >         }else{
> >
> >   print "Sorry, but you seem to have left one or more entries
blank.<br>\n";
> >   print "Please return to <a href=\"/prac/form.html\">form</a>\n";
> >   print " and complete the input<br>\n";
> >
> >}
> >**********************************************************************
>
>
>
> --
> 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]

Reply via email to