jmasterx
jmasterx

Reputation: 54113

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

Then 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

Upvotes: 0

Views: 107

Answers (3)

Cyclone
Cyclone

Reputation: 18295

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

Upvotes: 0

Josh
Josh

Reputation: 3475

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

Upvotes: 1

karim79
karim79

Reputation: 342635

You need to echo it:

<?php echo $imagePath ?>

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

<?=$imagePath ?>

Upvotes: 1

Related Questions