通过php设置img src?
这是我的问题 如果我这样做:通过php设置img src?,php,Php,这是我的问题 如果我这样做: $imagePath = "images/spalt_images/body_images/525A.JPG"; ?> <img src="<?php $imagePath ?>" alt="front image" class="productImage"/> <?php $imagePath=“images/spalt\u images/body\u image
$imagePath = "images/spalt_images/body_images/525A.JPG";
?>
<img src="<?php $imagePath ?>" alt="front image" class="productImage"/>
<?php
$imagePath=“images/spalt\u images/body\u images/525A.JPG”;
?>
“alt=”front image“class=”productImage“/>
你需要回应它:
<?php echo $imagePath ?>
或者使用短标记(不推荐,但这是另一个讨论):
您需要回显$imagepath,否则它将无法“打印”出来。将代码中的
更改为
,或者在服务器不允许短标签的情况下添加回显
<?php echo $imagePath ?>
<?=$imagePath ?>