2011-02-05 43 views
4

繼承人我的代碼:html_entity_decode不解碼ASCII

$string = '&#73&#116'; 
$string = html_entity_decode($string); 
echo $string; 

應該呼應「它」,但它只是呼應ASCII碼。我使用了錯誤的功能嗎?我也試過htmlspecialchars_decode,它什麼都不改變。

回答

9

這些都不是有效的實體其實,他們是在HTML 4有效的(我想HTML5太),但在這種情況下,實體需要被分號終止PHP來識別它們:

$string = 'It'; 

htmlspecialchars_decode()只解碼<,>,&,'"(和最後兩個依賴於引號標誌)。

+0

我試過html_entity_decode($ string,ENT_QUOTES,'ISO-8859-1')和 html_entity_decode($ string,ENT_QUOTES),他們都沒有工作。該字符串在我的頁面上使用ISO-8859-1。我使用$ string = html_entity_decode($ string,ENT_QUOTES,'ISO-8859-1') – scarhand 2011-02-05 20:32:19

相關問題