Click here to Skip to main content
15,890,670 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: And this is why I hate PHP (again) Pin
BobJanova3-Aug-12 4:59
BobJanova3-Aug-12 4:59 
GeneralRe: And this is why I hate PHP (again) Pin
OriginalGriff30-Jul-12 2:32
mveOriginalGriff30-Jul-12 2:32 
GeneralRe: And this is why I hate PHP (again) Pin
W Balboos, GHB30-Jul-12 3:33
W Balboos, GHB30-Jul-12 3:33 
AnswerRe: And this is why I hate PHP (again) Pin
Moshe Katz30-Jul-12 4:08
Moshe Katz30-Jul-12 4:08 
GeneralRe: And this is why I hate PHP (again) Pin
W Balboos, GHB30-Jul-12 4:24
W Balboos, GHB30-Jul-12 4:24 
GeneralRe: And this is why I hate PHP (again) Pin
W Balboos, GHB2-Aug-12 8:27
W Balboos, GHB2-Aug-12 8:27 
GeneralRe: And this is why I hate PHP (again) Pin
ptcmariano30-Jul-12 5:14
ptcmariano30-Jul-12 5:14 
GeneralRe: And this is why I hate PHP (again) Pin
Florin Jurcovici30-Jul-12 2:54
Florin Jurcovici30-Jul-12 2:54 
I don't like PHP either, but this looks like a simple matter of operator precedence to me.

The precedence of operators is well defined in PHP. +/-/. have higher precedence than ?:, so the outcome is IMO reasonable, and in no way weird.

Consider this: x == 2 ? 14 : 2 * 7. Would you expect "* 7" to be evaluated after the ?: in this case?

Some people recommend redundant parentheses precisely for avoiding such situations - it's not just a matter of correctness, it's also a matter of expressiveness - the variant without parantheses is potentially misleading, even when it's intended.
GeneralIt doesn't stop there Pin
Jecc30-Jul-12 12:29
Jecc30-Jul-12 12:29 
GeneralRe: And this is why I hate PHP (again) Pin
riggaP30-Jul-12 13:35
riggaP30-Jul-12 13:35 
GeneralRe: And this is why I hate PHP (again) Pin
fuximus2-Aug-12 18:11
fuximus2-Aug-12 18:11 
GeneralI don't got time for no stinking opera! Pin
enhzflep22-Jul-12 8:30
enhzflep22-Jul-12 8:30 
GeneralRe: I don't got time for no stinking opera! Pin
Brisingr Aerowing22-Jul-12 12:45
professionalBrisingr Aerowing22-Jul-12 12:45 
GeneralRe: I don't got time for no stinking opera! Pin
_Amy22-Jul-12 22:29
professional_Amy22-Jul-12 22:29 
GeneralRe: I don't got time for no stinking opera! Pin
enhzflep22-Jul-12 22:54
enhzflep22-Jul-12 22:54 
GeneralRe: I don't got time for no stinking opera! Pin
CDP180222-Jul-12 23:03
CDP180222-Jul-12 23:03 
GeneralRe: I don't got time for no stinking opera! Pin
enhzflep22-Jul-12 23:44
enhzflep22-Jul-12 23:44 
GeneralRe: I don't got time for no stinking opera! Pin
Jochen Arndt23-Jul-12 0:58
professionalJochen Arndt23-Jul-12 0:58 
GeneralRe: I don't got time for no stinking opera! Pin
Andrei Straut23-Jul-12 1:15
Andrei Straut23-Jul-12 1:15 
GeneralRe: I don't got time for no stinking opera! Pin
enhzflep23-Jul-12 2:12
enhzflep23-Jul-12 2:12 
GeneralRe: I don't got time for no stinking opera! Pin
Chris Maunder30-Jul-12 15:16
cofounderChris Maunder30-Jul-12 15:16 
GeneralRe: I don't got time for no stinking opera! Pin
Brisingr Aerowing30-Jul-12 15:24
professionalBrisingr Aerowing30-Jul-12 15:24 
GeneralRe: I don't got time for no stinking opera! Pin
enhzflep23-Jul-12 2:11
enhzflep23-Jul-12 2:11 
GeneralWhat condition, or lack thereof, am I even testing for again??? Pin
nedmech20-Jul-12 13:24
nedmech20-Jul-12 13:24 
GeneralRe: What condition, or lack thereof, am I even testing for again??? Pin
Brisingr Aerowing21-Jul-12 4:27
professionalBrisingr Aerowing21-Jul-12 4:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.