为什么html_entities_decode没有解码html实体?

时间:2014-03-02 11:36:44

标签: php

我有这段代码:

$string = "Perfect Valentine's Day Care Package | SpouseBuzz.com";
echo $string ."\n";
echo html_entity_decode($string) ."\n";

它返回:

Perfect Valentine's Day Care Package | SpouseBuzz.com
Perfect Valentine's Day Care Package | SpouseBuzz.com

我的问题是:为什么html_entity_decode没有转换html实体?

谢谢!

1 个答案:

答案 0 :(得分:3)

默认情况下,

html_entity_decode()只会转换双引号并且会单独留下单引号。要将单引号转换为相应的字符,请添加ENT_QUOTES标志:

echo html_entity_decode($string, ENT_QUOTES, 'UTF-8');

Online demo