Re: Re: Switch statement Question
| From: | Jochem Maas | Date: | Fri, 30 Jan 2009 15:16:17 +0000 |
| Subject: | Re: Re: Switch statement Question | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287420@lists.php.net to get a copy of this message | ||
tedd schreef:
> At 4:43 PM -0500 1/29/09, Frank Stanovcak wrote:
>> >"
>>
>> yes...that is legal. as long as the statment resolves to a boolean it
>> will
>> work. It's not technically correct, but it does work.
>
> There you go again. What's technically correct?
hiya tedd,
you mean to ask "not technically correct" ... I plead
that it's his statement that is not technically correct.
1. php does a soft comparison ('==' rather than '===') so the
results of each case expression is auto-cast to a boolean
(in the case of switch'ing on TRUE), ergo there is no 'as long',
statements will always resolve to a boolean ... only they may not
do it in a way that is readily understood by everyone.
2. the php engine specifically allows for 'complex expression'
cases testing against a boolean switch value ... not best practice
according to some but very much technically correct according to
the php implementation.
> Cheers,
>
> tedd
>