Because double-quotes are a really bad idea anyway (due to the variable expansion), I would suggest that preg_replace's auto-escaping is modified to suit the placement of backreferences inside single-quotes (which seemed to be the intention from the start, but was incorrectly applied)."---------------------Heeeeeeeeeeeeeeeeeeeello Woooooooooooooooorld!!!!!!!!!!!!!!!!!!!!!!!!
===============================================================================================================~~~~~~~~~~~~~~~~ ~ ~ ~" I find it useful to output HTML form names to the user from time to time while going through the $_GET or $_POST on a user's submission and output keys of the GET or POST array...
the only problem being in the name attribute I follow common programming guidelines and have names like the following: event Date, event Time, user Email, etc.
Not great to just output to the user-- so I came up with this function.
If you surrounded your backreference by single-quotes, the double-quotes are corrupt:$text = str_replace('\"', '"', $text); People using preg_replace with /e should at least be aware of this.
I'm not sure how it would be best fixed in preg_replace.
Using double-quotes to surround the string/backreference will not help either, because inside double-quotes, the sequence \' is not recognized and also output literally.
And in fact, if you have any dollar signs in your data, they would be interpreted as PHP variables. The 'solution' is to manually fix it in your expression.
This is due to the PCRE library returning an error code if the string contains bad UTF-8.
People using the /e modifier with preg_replace should be aware of the following weird behaviour.
It is not a bug per se, but can cause bugs if you don't know it's there.