开发者

setting the img src via php?

Here is my problem.

If I do:

  $imagePath = "images/spalt_images/body_images/525A.JPG";
              ?>
<img src="<?php $imagePath ?>" alt="front image" class="productImage"/> 
               <?php

Th开发者_运维问答en my image does not show up.

However, if I do:

<img src="images/spalt_images/body_images/525A.JPG" alt="front image" class="productImage"/> 

Then my image shows up just fine. Why would it not work with php?

Thanks


You need to echo it:

<?php echo $imagePath ?>

or use a short tag (not recommended, but that's another discussion):

<?=$imagePath ?>


You need to echo $imagepath otherwise it won't 'print' it out.


Change <?php $imagePath ?> in your code to <?=$imagePath?>, or add an echo if your server doesn't allow shorttags.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜