Echo does not return image path in HTML style attribute [closed]

0

I did the following

echo"<div class='carousel-item active' style='background-image: url('img/intro-carousel/". $row["img_pag_princ_car"] . "')>"

But you're returning the following:

<div class="carousel-item active" style="background-image: url(" img="" intro-carousel="" 01_gigaclima_indoor.jpg')="">

What am I doing wrong? Why are you replacing / with ?

    
asked by anonymous 05.03.2018 / 17:08

1 answer

2

The problem is the quotation marks, you are missing out on the interpolation. Try to escape the quotes:

echo  "<div class=\"carousel-item active\" style=\"background-image: url('img/intro-carousel/". $a . "')\">";
    
05.03.2018 / 18:28