Re: Re: Switch statement Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux