note 6006 deleted from Logical Operators by jimw
| From: | jimw@php.net | Date: | Thu, 11 Jan 2001 03:01:59 +0000 |
| Subject: | note 6006 deleted from Logical Operators by jimw | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9620@lists.php.net to get a copy of this message | ||
"or" is not like Perl's "or". It's a variant precidence version of ||
which is useful only in comparisons. IOW: <pre>$x = foo() or bar()</pre> will assign
foo() to $x regardless of foo()'s value. It then does a ( $x or bar() ) which just goes into
nothingness, though bar() should be called if there are any side-effects.
What you need to do is:
<pre>if( !$x = foo() ) $x = bar();</pre>