Re: switch with case 0 [message #182628 is a reply to message #182626] |
Sun, 18 August 2013 23:35 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 18/08/13 23:13, Thomas Mlynarczyk wrote:
> No. First it did its weird comparison and then it passed the
> resulting boolean to strlen() and strlen() didn't complain, converted
> the boolean to string, did its stuff, returned an integer which got
> converted to a boolean to evaluate the if condition. If you ever make
> a mistake and want to hide it -- put it in a PHP script, it'll be safe
> there ;-)
>
At least you only have ONE implementation of PHP to contend with.
When I did similar in Javascript it took me TWO BLOODY DAYS to work out
why exactly the same code worked in Firefox and not in IE6.
And it was EXACTLY the same issue. comparing what I ASSUMED were
numbers, but they got converted to strings by IE6,
But not by firefox.
It took me one and a half days to pin the thing down, and half a day to
find a construct that actually did the same thing in both browsers.
sheesh.
I even looked up the spec. It didn't cover the case. casting is
explicitly defined in ASSIGNMENTS, but not in COMPARISONS.
> Greetings,
> Thomas
>
>
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
|
|
|