note 30637 deleted from control-structures by didou
| From: | didou@php.net | Date: | Sat, 09 Aug 2003 04:48:53 +0000 |
| Subject: | note 30637 deleted from control-structures by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-53734@lists.php.net to get a copy of this message | ||
Note Submitter: ian at iyates dot com
----
In response to LexZEUS:
If you used the same code with | instead of || and & instead of && (as follows)
function lex1()
{
print "Hello";
return 1;
}
function lex2()
{
print "World";
return 1;
}
if (lex1() | lex2()) {}
if (
@function1() &
@function2() &
@function3() &
@function4() &
@function5()) {}
All functions would be executed before the final boolean is returned.
Although || and && are more useful (efficient and easy to understand), | and & are
normally used when some functions _have_ to be executed even if one fails.
a good example is:
if (isset($a) && $a == 'hello')
echo $a;
if (isset($b) & $b == 'world')
echo $b;
while the first 'if' will always be okay, the second will return an error if $b had not
been set as it will still compare $b to 'world' (which should return 'false' and
a warning)