Re: solved [message #185751 is a reply to message #185730] |
Tue, 06 May 2014 00:55 |
Doug Miller
Messages: 171 Registered: August 2011
Karma:
|
Senior Member |
|
|
richard <noreply(at)example(dot)com> wrote in news:1u66bqszrlp57$.2ce1bbokt163.dlg@
40tude.net:
[...]
> if ($file !== '.' || $file!=="..")
> $master[] = $file;
> This does not seem to work.
Depends on your definition of "work", I suppose. It definitely does work, in the sense that it
certainly is doing what you told it to. I'm pretty sure it's not doing what you expected it to do,
but that's because your expectations don't match your code.
Consider what happens when $file is equal to "." The first part of your compound condition
is FALSE. The second part is TRUE.
FALSE || TRUE is TRUE.
Now what happens when $file is equal to "..". The first part is TRUE, and the second part is
FALSE.
TRUE || FALSE is TRUE.
Finally, if $file is equal to, say, "abc". Now both parts of the condition are TRUE.
TRUE || TRUE is TRUE.
The results you *want* are FALSE, FALSE, TRUE respectively -- that is, you want the result
to be FALSE when *either* of its inputs is FALSE, and TRUE only if *both* of its inputs are
TRUE. That describes &&, not ||.
>
> Time to implement the formidable goto eh?
No, it's time to fix your broken logic. Google "De Morgan's Laws" for more information.
|
|
|