【发布时间】:2018-05-01 14:23:37
【问题描述】:
我的代码总是有这个问题:
<?php
$imgurl = "https://cdn.jsdelivr.net/example.png";
$get_style = 'background-image: url(\''.$imgurl.'\'); ';
?>
<figure id="centerbg" class="centerbg" style="<?php echo $get_style; ?>background-position: center center;background-attachment: inherit;">
但无论我做什么,html 总是显示:
<figure id="centerbg" class="centerbg" style="background-image: url("https://cdn.jsdelivr.net/example.png"); background-position: center center; background-attachment: inherit;">
我也试过了:
<figure id="centerbg" class="centerbg" style="background-image: url(<?php echo $imgurl ?>);background-position: center center;background-attachment: inherit;">
但是一点用处都没有!
谁能帮帮我? TAT
感谢您的帮助,但似乎我和您的代码在这个单个文件中都可以正常工作:https://api.mashiro.top/cover/test.php,但总是在我的生产站点中获得转义字符(与封面图像相同的 HTML id):https://2heng.xin/ ,真的很奇怪,而且我的网站中的其他部分是否有可能出错?
我不知道为什么style="background-image: url(&quot;https://cdn.jsdelivr.net/example.jpg&quot;);" 可以在我的浏览器(Chrome 和 Firefox)中显示图像,但这不是一个好的表达方式呃?
【问题讨论】:
-
@Marko Paju 还是不行...而且我的 PHP 文件在 ANSI...