What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

This question already has an answer here:

I just answered my own question here (GeoPheonix answered in the comments but didn't provide a full answer), and the string in the code isn't displaying correctly:

string error

This may seem like a minor nitpick but in this case it could cause confusion as the issue was related to the ?>. (and as we all know, users shouldn't have to think)

share|improve this question

marked as duplicate by ben is uǝq backwards, Rory, Martijn Pieters, Lucifer, Mat Jun 15 '13 at 16:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Sorry I tried to edit but didn't do a very good job. What if you use double-quotes in both cases, e.g. echo "stuff\"otherstuff" - maybe this won't trip up the syntax highlighter so badly? Anyway there are some cases that just aren't always handled perfectly by the syntax highlighter, e.g. strings that end in \ like SET @folder = 'd:\folder\'; - this wreaks havoc on the syntax highlighting until the next ' is hit. You could spend a lot of time trying to work around this or you can just trust that readers will copy the code and only bitch and moan if it actually doesn't work. –  Aaron Bertrand Jul 10 '12 at 14:21
1  
Cheated and told the highlighter it was Javascript ;) –  Daniel Fischer Jul 10 '12 at 14:25

1 Answer 1

up vote 4 down vote accepted

The problem the syntax highlighter is having here is actually very similar to the problem the user in that question had: Prettify sees the first ?> and considers it to end the PHP part of the code, not realizing that it appears in a string constant.

Given the way prettify works, this unfortunately is unfixable. It's similar to why you shouldn't have </script> in a JavaScript string constant within an HTML page – at the time that the ending tag is seen, the parser doesn't yet know about the concept of string constants.

Fortunately this is just a small edge case, and Daniel Fischer has found a nice workaround.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged .