2017-02-16 153 views
0

在下面的代码:PHP html_entity_decode不按预期解码实体?

$string1 = "function doesn't work as expected"; 
$string2 = html_entity_decode($string1); 

$字符串2仍包含:

' 

...之后调用html_entity_decode()。

我已经检查过有关此主题的其他SO线程,但还没有找到答案。我错过了什么?

回答

3

default flags对于html_entity_decode不包括单引号。尝试更新您的标志参数以包含ENT_QUOTESENT_HTML5

$string1 = "function doesn't work as expected"; 
echo $string2 = html_entity_decode($string1, ENT_QUOTES|ENT_HTML5); 
// function doesn't work as expected