FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » switch says value is equal to case when it is not
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: switch says value is equal to case when it is not [message #184668 is a reply to message #184666] Tue, 14 January 2014 21:09 Go to previous messageGo to previous message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma:
Senior Member
richard <noreply(at)example(dot)com> wrote in news:x76wm4qeiagq.vnb3xbwh1l0o$.dlg@
40tude.net:

> case 60 || 61 || 62 || 63 || 64 || 65 || 66 || 67 || 68 || 69:

For at least the third time now, RtS: This does NOT work the way you think it does.

It does *not* test to see if the value of the switch variable is equal to 60 or 61 or ... or 69.

Instead, it compares the value of the switch variable to the bitwise logical conjunction 60 ||
61 || 62 || ... || 69 which necessarily is a true value -- thus any non-zero value of the switch
variable will match.

The same issue naturally affects the other two 'case' statements which you have also
coded incorrectly.

It would also behoove you to read about, and understand, the use of the 'break' command
inside 'switch'.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: php.ini loading
Next Topic: How to locally install Wordpress, Ubuntu 8.10 , XAMPP already installed.
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 21:25:33 GMT 2024

Total time taken to generate the page: 0.04259 seconds