2014-03-02 34 views
0

我有這樣的代碼:爲什麼html_entities_decode不能解碼html實體?

$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實體?

謝謝!

回答

3

html_entity_decode()默認情況下只會轉換雙引號,並且會留下單引號。也轉換單引號其對應的字符,添加ENT_QUOTES標誌:

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

Online demo

+0

這工作!謝謝 – jollyr0ger