使用php echo显示图像时,Firefox和Explorer的行为会有所不同

使用php echo显示图像时,Firefox和Explorer的行为会有所不同

问题描述:

The image box on this page "http://www.ebookfetcher.com/bookdeals/index.php?pid=23" appears in Firefox and Explorer, but not Chrome and Safari. How do I make it invisible for all of them when $bookpage_coverimage is empty?

<a href="http://www.ebookfetcher.com" class="linkstyle"><img src="<?php echo $bookpage_coverimage ?>" width="260"></a>

此页面上的图像框“ http://www.ebookfetcher.com/bookdeals/index.php?pid=23 ”出现在Firefox和资源管理器中,但不出现在Chrome和Safari中。 当$ bookpage_coverimage为空时,如何让它对所有这些都不可见? p>

 &lt; a href =“http://www.ebookfetcher.com”class =“linkstyle  “&gt;&lt; img src =”&lt;?php echo $ bookpage_coverimage?&gt;“  width =“260”&gt;&lt; / a&gt; 
  code>  pre> 
  div>

With a simple if statement in PHP.

<?php if($bookpage_coverimage !=""){ ?><a href="http://www.ebookfetcher.com" class="linkstyle"><img src="<?php echo $bookpage_coverimage ?>" width="260"></a><?php } ?>

Should do the trick, it will not output any html if its empty.