1

I'm using gettext to translate my website. One key has a translations with a html tag:

msgid "BANNER_TAG_START"
msgstr "<!-- // MY BANNER TAG -->"

if I use this code in php now:

var_dump(htmlspecialchars(gettext('BANNER_TAG_START')));

it normally should returns:

<!-- // MY BANNER TAG -->

most times it works like this, but sometimes I get:

MY BANNER TAG

Why do I sometimes get this wrong code?

4

1 回答 1

0

In my env, running the following code,

var_dump(htmlspecialchars("<!-- // MY BANNER TAG -->"));

returns this,

string(31) "&lt;!-- // MY BANNER TAG --&gt;"

not

<!-- // MY BANNER TAG -->

as you reported. So I assume you are reporting the final rendered text on your browser, instead of the generated HTML source code.

Please check the 3-5 in 100 times where the problem happen in the generated HTML source code, and check if the what kind of other letters or line-breaks exist BEFORE the "<!-- //", then you may find the difference for the 3-5 cases.

于 2012-11-10T02:06:31.083 回答