首页 > html字符转义问题

html字符转义问题

我有这么一段代码:

#include <stdio.h>
int main(int argc, char *argv[])
{
     printf("%d", a + b);
}

我先用htmlspecailchars处理后存入数据库,得到如下形式的代码:

#include &amp;lt;stdio.h&amp;gt;
int main(int argc, char *argv[])
{
     printf(&amp;quot;%d&amp;quot;, a + b);
}

然后我从数据库读出来,并且用htmlspecialchars_decode解码后输出到一个div中,得到的是如下的结果:

#include &lt;stdio.h&gt;
int main(int argc, char *argv[])
{
     printf(&quot;%d&quot;, a + b);
}

我想要的结果是最后显示在html页面中的代码和我输入的代码一样的,请问我的处理步骤哪里除了问题?谢谢


HTML转义:

所以你的&amp;quot;是被转了两次:

  1. 第一次将"转为&quot;
  2. 第二次将&quot;的第一个&转为&amp;

为什么被转换了两次由于没有代码无从查起,但保底的解决方案是调用两次htmlspecialchars_decode


我觉得你在存入数据库的之前应该是做了两次htmlspecailchars? 走查下代码看看

【热门文章】
【热门文章】