今天碰到数据库中存储“& mdash;& mdash;”,是 “——”对实体标签的转意。
数据发送到邮箱中,发现没有被反转。
htmlentities 与 html_entity_decode 作为转与反转的配对,我用html_entity_decode(“— —” )测试失败。
以为被zend_filter_htmlentities做了手脚,打开源码才明白.
zf代码有这样一段:
htmlentities((string) $value, $this->getQuoteStyle(), $this->getEncoding(), $this->getDoubleQuote())
实际执行的是 : htmlentities($value, ENT_COMPAT, 'UTF-8', 1);
而zf目前没有提供反转函数,那最终执行:html_entity_decode ($value, ENT_COMPAT, 'UTF-8'); 解决