Re: Boolean type forced on string assignment inside if statement
| From: | tamouse mailing lists | Date: | Sat, 05 Jan 2013 01:58:59 +0000 |
| Subject: | Re: Boolean type forced on string assignment inside if statement | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-320033@lists.php.net to get a copy of this message | ||
On Fri, Jan 4, 2013 at 4:25 PM, Sebastian Krebs <krebs.seb@gmail.com> wrote:
> 2013/1/4 tamouse mailing lists <tamouse.lists@gmail.com>
>
>> On Fri, Jan 4, 2013 at 1:56 AM, Sebastian Krebs <krebs.seb@gmail.com>
>> wrote:
>> > 2013/1/4 tamouse mailing lists <tamouse.lists@gmail.com>
>> >> Bit operators are not comparing values, they're COMBINING values.
>> >
>> > Technically spoken they're comparing bits, whereas boolean operators does
>> > the same, but treaten every value as a single bit.
>>
>> And that's just going to confuse things. "Technically" speaking, bit
>> operations and NOT logical operations. If you do this:
>>
>> if ($a & $b)
>>
>> when you meant this:
>>
>> if ($a && $b)
>>
>> it's because you got lucky, not because it's correct.
>>
>
> Sorry, but ... well, I don't understand you :X
>
> When I want "&&" and type "&" it's simply a bug, but
> sometimes I want "&",
> for example like in "$a & FLAG_ALLOWED", so I don't know, what you are
> talking about right now
I'm talking about the first case, when it's a bug.
Missing important words;
"*and it works*, it's because you got lucky, not because it's correct"