PHP Concatenating of image link in echo

2019-09-16 11:31发布

问题:

I want to echo the image such that the variables $CatSelected will be the folder of the images and $char and $i are part of the img names : e.g

echo "<img src =\"Images/product/".$CatSelected."/".$char$i."s0.jpg"\>";

回答1:

 echo "<img src =\"Images/product/".$CatSelected."/".$char.$i."s0.jpg\"\>";
                                                          ^          ^

1) You forgot to concatenate $char and $i.

2) You forgot to escape the double quotes.



回答2:

try this

echo "<img src ='Images/product/'".$CatSelected."/".$char$i."'s0.jpg'\>";