D
12

Spent 4 hours chasing a semicolon that wasn't there

My PHP script kept throwing a parse error, and I finally found out it was an invisible Unicode character from some random copy-paste. Has anyone else lost a whole evening to something like that?
3 comments

Log in to join the discussion

Log In
3 Comments
paul_thompson67
That invisible character stuff is brutal, but what gets me is the opposite problem. You spend all that time hunting for a semicolon that's not there, and half the time it turns out the real issue is something dumb like a missing closing bracket on line 47 that just makes the parser blame the next line. I've started keeping a text editor with a hex view open just to spot those zero-width space gremlins before they eat my night. My trick now is to paste anything from docs into a plain editor first, then copy it again into the code. Saves me most nights, but man, when it's 2am and you're squinting at invisible characters, you start questioning every life choice that led you to PHP.
1
the_uma
the_uma24d agoTop Commenter
ngl I used to think the hex view thing was overkill, like just trust your eyes and read the code. But after one too many nights chasing a ghost that turned out to be a zero-width space from some random docs copy, I get it now, that trick actually saves your sanity. Honestly, pasting into plain text first feels dumb but it's the real pro move, and I'm stealing it for every project from here on.
6
bettyk53
bettyk5324d ago
Honestly, the "missing closing bracket on line 47" thing hits way too close to home for me. I finally stopped fighting it and started running a linter that points to the exact char, but before that, I'd just paste the whole block into VS Code and collapse the sections until the colors told me where it broke. Tbh, that 2am moment where you question PHP is real, but once you learn to trust the error message over your eyes, it gets way less painful.
1