PHP吐出实际的HTML而不是图像

时间:2015-07-08 09:03:27

标签: php html

这里有一个小问题,但无法弄清楚我哪里出错了。我有以下代码,应根据条件显示图像,但它在浏览器中显示HTML

if ($this->id_status  == 2)
    {
            $this->id_status  = "<img src='../_lib/img/gray_dot.png' />";
    }
elseif ($this->id_status  == 1)
    {
            $this->id_status  = "<img src='../_lib/img/green_dot.png' />";
    }
elseif ($this->id_status  == 3)
    {
            $this->id_status  = "<img src='../_lib/img/orange_dot.png' />";
    }

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

试试这个:

<?php

    if ($this->id_status  == 2)
        {
   ?>
<img src='../_lib/img/gray_dot.png' />
<?php
        }
    elseif ($this->id_status  == 1)
        {
?>
               <img src='../_lib/img/green_dot.png' />
<?php

        }
    elseif ($this->id_status  == 3)
        {
?>
<img src='../_lib/img/orange_dot.png' />
<?php

        }
?>