Police Procedural Programming
Oct. 25th, 2010 02:53 pmProgramming a web app while watching a police procedural is a good idea. Every mystery is a learning opportunity. Why is my PHP code generating HTML with an extra linebreak? There is no \n at that spot in the code. I don my sunglasses. Even though it's nighttime. Darkness doesn't matter. Always wear sunglasses at the scene of a crime.
That spot in the code is a red herring. It's clean. Suspicion now turns on the comma-separated values file. Its fingerprints are all over this. The extra linebreak happens to coincide with the end of a line in that file.
But no. The CSV itself was just a patsy... The real culprit forced it to do this. The real culprit was there with me all along, watching the whole investigation, inviting no suspicion. I remove my sunglasses in a dramatic flourish.
Turns out a part of the code, the part that reads my comma-separated-values file into the program, is also reading in the linebreak at the end of each line. It should have stripped that out first. It thought no one would notice. It thought if it hid the evidence in the view-source, no one would ever be the wiser. No one looks at a linebreak. A line lying there, broken, outlined in chalk. It thought no one cares about a castoff of society. Internet Explorer will just look the other way, with the approval of the mayor and the police chief... it goes all the way to the top. It thought no one would miss the vic. It thought wrong. I don my sunglasses.
It didn't actually make any practical difference to the outcome. But someday it might. And now... I'll be ready for it. Cue musical montage.
That spot in the code is a red herring. It's clean. Suspicion now turns on the comma-separated values file. Its fingerprints are all over this. The extra linebreak happens to coincide with the end of a line in that file.
But no. The CSV itself was just a patsy... The real culprit forced it to do this. The real culprit was there with me all along, watching the whole investigation, inviting no suspicion. I remove my sunglasses in a dramatic flourish.
Turns out a part of the code, the part that reads my comma-separated-values file into the program, is also reading in the linebreak at the end of each line. It should have stripped that out first. It thought no one would notice. It thought if it hid the evidence in the view-source, no one would ever be the wiser. No one looks at a linebreak. A line lying there, broken, outlined in chalk. It thought no one cares about a castoff of society. Internet Explorer will just look the other way, with the approval of the mayor and the police chief... it goes all the way to the top. It thought no one would miss the vic. It thought wrong. I don my sunglasses.
It didn't actually make any practical difference to the outcome. But someday it might. And now... I'll be ready for it. Cue musical montage.