Вопрос

Here is a section of my code which should add the background image to a label, but for some reason when I start using <?= shorthand, all of the forward slashes are being removed:

<label for="<?=$result_id?>_checkbox" id="<?=$result_id?>_label" style="background-image:url("<?=$img?>");" />

Here is the code that generates the URL:

$img = $_SESSION['ROOT_DIR']."data/images/".$folder."/".$result_imageset."/".str_replace(" ", "%20", $result_jpg);

This is what that $img variable generates:

http://localhost:1234/ppa/data/images/20140130/0/RMEuvh3.jpg

Edit:

echo var_dump(ini_get('short_hand_tags'));

Produces:

bool(false)

Although, the following works...

<div class="jpg"><?=$result_jpg?></div>
Это было полезно?

Решение

Have a look at the source code of the page being generated. It works for me, in the sense that forward slashes are not removed.

However there is problem with your code:

style="background-image:url("<?=$img?>");"

You have double quotes within double quotes. That will not work :)

you want this instead

style="background-image:url('<?=$img?>');" <-- inner double quotes replaced with single quotes.

Other than that your code renders as expected.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top