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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.