15 Most Recent [RSS]
More...
|
Denkste: Stupid mistakes that we keep on making
In German, there's the word "denkste". My dictionary says the English translation is "That's what you think!". This word precisely describes how I felt after fixing a bug in my web site. There was a bug in the PHP code for HTML-encoding the descriptions in my application lists, which caused every single line break to be turned into two <br> tags.
You may have noticed it, and it looked atrocious. So, after un-registering from my last exam today and finding out that they wouldn't need me at rehearsal tonight, I thought I'd finally squish that bugger. And what do you know, it was a typical case of denkste: I was using implode() to glue together the array of lines I'd read using file(). Now, I knew that file() returns each line as a new array item but doesn't remove the line breaks from the end of the array items. I also knew that calling implode("\n", $array) would insert a line break between the lines it glues together. What I'd failed to notice until checking things again today, was that line feed at end of array item + line feed inserted between array items = 2 line feeds.
So, I thought: "I know how this works, I wouldn't make that stupid mistake", and the computer said denkste!. It's the kind of mistake every person occasionally makes. When next you do it, feel free to remember denkste. It's too precise a word not to be popularized beyond this little European country. | |