简体   繁体   English

背景图片标签中的 PHP

[英]PHP in Background-image tag

On a Wordpress theme site I have this code:在 Wordpress 主题网站上,我有以下代码:

<div class="gallery-img" style="background-image: url(<?php echo esc_url($image['sizes']['thumbnail']); ?>);">

However I need the background image url to be in ''.但是我需要将背景图像 url 放在 '' 中。

So it works like this:所以它是这样工作的:

<div class="gallery-img" style="background-image: url('<?php echo esc_url($image['sizes']['thumbnail']); ?>');">

With it like that the PHP then does not work, how can I do the above so it works and so it has the '' around it?这样一来,PHP 就不起作用了,我如何才能执行上述操作以使其有效,并且它周围有 '' ?

如何反转你的单引号和双引号?

<div class="gallery-img" style='background-image: url("<?php echo esc_url($image['sizes']['thumbnail']); ?>");'>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM