|
Posted by Jam Pa on 05/25/05 18:54
Jam Pa <anonanon@non-anon.org> wrote in
news:Xns9661B5FF25BABanonanonnonanonorgjp@213.243.153.2:
> Both '&' and '&&' are 'AND' right? Or what about 'ORs' '|' and '||'?
> Whats the difference? I not grok....
Here is an example test for those interested.
<?php
$a = "nil"; $b = "nil";
if (($a=true) | ($b=false)) { echo " * 1: true, a: $a , b: $b <br>"; }
$a = "nil"; $b = "nil";
if (($a=false) | ($b=true)) { echo " * 2: true, a: $a , b: $b <br>"; }
$a = "nil"; $b = "nil";
if (($a=true) || ($b=false)) { echo " * 3: true, a: $a , b: $b <br>"; }
$a = "nil"; $b = "nil";
if (($a=false) || ($b=true)) { echo " * 4: true, a: $a , b: $b <br>"; }
$a = "nil"; $b = "nil";
?>
output with comments
* 1: true, a: 1 , b:
* 2: true, a: , b: 1
- both evaluated above
* 3: true, a: 1 , b: nil
- only first one evaluated (it was true)
)
* 4: true, a: , b: 1
- both
Hmm, not sure if I'm really any wiser...
[Back to original message]
|