2012-08-02 144 views
0

目前我正在嘗試使用html_entity_decode在同一頁上顯示2個圖像。使用html_entity_decode顯示圖像

$ent = file_get_contents('./olympic.jpg'); 
    $ent1 = file_get_contents('./olympic1.jpg'); 
    $s = htmlspecialchars($ent1,ENT_COMPAT,'iso-8859-1'); 
    $s1 = htmlspecialchars($ent,ENT_COMPAT,'iso-8859-1'); 

    $s2 = html_entity_decode($s, ENT_COMPAT,'iso-8859-1'); 
    $s3 = html_entity_decode($s1, ENT_COMPAT,'iso-8859-1'); 

    Header("Content-Type: image/jpeg"); 
    echo ($s2); 
    echo ($s3); 

我現在可以顯示$ s2但無法顯示$ s3。這只是一個測試頁面,在真實系統中,圖像將通過iso-8859-1編碼從webservices發送。任何幫助,將不勝感激。

+0

你可能想檢查[這個問題](http://stackoverflow.com/questions/11705229/display-multiple-images-with-php/11705307)。 – Vatev 2012-08-02 06:15:33

+0

謝謝我得到了我的回答:) – 2012-08-02 14:58:01

回答

2

這與html_entity_decode()無關。您無法在單個HTTP響應中顯示兩個圖像。您必須提供包含兩個嵌入圖像的HTML文檔(Content-Type:text/html)。