简体   繁体   English

php gettext无法加载html标签

[英]php gettext fails loading html tag

I'm using gettext to translate my website. 我正在使用gettext来翻译我的网站。 One key has a translations with a html tag: 一键翻译成html标签:

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

if I use this code in php now: 如果我现在在php中使用此代码:

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? 为什么有时我会收到错误的代码?

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. 因此,我假设您是在浏览器中报告最终呈现的文本,而不是生成的HTML源代码。

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. 请检查生成的HTML源代码中出现问题的100次中的3-5次,并检查在“ <!-//”之前是否存在其他类型的字母或换行符,然后您可能会发现区别为3-5例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM