2017-02-16 154 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