2012-08-02 143 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)。