php代码点火器选择检索问题


php code igniter select retrieve issue

嗨,我正在为网站使用代码点火器框架

这是一个技术文章网站,我正在添加不同语言的文章。

当我把文章和例如的代码一起保存时,它正确地插入了数据库。

<pre class="prettyprint" id="html">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<head>
    <meta name="copyright" content="Atos Origin" />
    <title>Select Option Demo Using Tapestry</title>    
</head>
<body>
    <h1>Payment Card Demo</h1>              
    <form t:type="form" t:id="cardForm" id="cardForm" method="post">
        <t:label for="cardTypes"/>
        <t:select t:id="cardTypes"/>
    </form>
</body>
</html>
</pre>

但当我从数据库中检索它进行编辑时,它会转换为实际的代码。

<pre class="prettyprint" id="html">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<head>
    <meta name="copyright" content="Atos Origin" />
    <title>Select Option Demo Using Tapestry</title>    
</head>
<body>
    <h1>Payment Card Demo</h1>              
    <form t:type="form" t:id="cardForm" id="cardForm" method="post">
        <t:label for="cardTypes"/>
        <t:select t:id="cardTypes"/>
    </form>
</body>
</html>
</pre>

但我不想这样的转换,那么有什么解决方案吗?

有一个PHP解决方案:

要将HTML编码为等效字符,请使用:

string htmlentities ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = 'UTF-8' [, bool $double_encode = true ]]] )

请参阅:http://www.php.net/manual/en/function.htmlentities.php

要解码为html,请使用:

string html_entity_decode ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = 'UTF-8' ]] )

建议:

当插入数据库时,我不会将html编码为特殊字符,只有当使用上面指定的函数将其拉出时。