use*_*091 4 php encoding special-characters
我们有这些字符:
“ 和 ”
(这不是常规的",而是某种卷曲的.不知道它叫什么)
当我们使用时htmlentities(),这些字符不会被转换,这会在以后引起问题.进一步的问题是我们对页面进行编码Latin-1,并且我们无法保存这个特定的字符(所以我们不能进行替换和查找,因为我们实际上无法将其编程到任何页面中).
注意:我们设置ENT_QUOTES,但这没有效果htmlentities().
UPDATE
我现在知道他们被称为花哨的引用,其中,他们适当的html实体是“和”.现在,问题是,为什么PHP 不能正确转换这些字符?请参阅示例代码:
<?php
var_dump(htmlentities($_POST['t'],ENT_QUOTES));
?>
<form action="" method="post">
<input type="t" name="t" />
<button class="button" type="submit">Send</button>
</form>
Run Code Online (Sandbox Code Playgroud)
结果:

使用htmlentities() 它涵盖具有等效html实体的所有字符.
UPDATE
你需要改变charset.
echo htmlentities("“jrod”", ENT_QUOTES, "Windows-1252");
更新2
<?php
var_dump(htmlentities($_POST['t'],ENT_QUOTES, "Windows-1252"));
?>
<form action="" method="post">
<input type="t" name="t" />
<button class="button" type="submit">Send</button>
</form>
Run Code Online (Sandbox Code Playgroud)
使用字符串: “testing”
Var转储输出: string(21) "“testing”"
请注意,要查看html等效项,您必须查看源代码,因为浏览器会相应地呈现它们.