简体   繁体   English

在背景图片中插入php变量

[英]Inserting a php variable in background-image

I'm trying to build a widget for a website that displays a random background image everytime the page is refreshed and i'm running into some trouble with string concatenation. 我正在尝试为网站构建一个窗口小部件,该页面每次刷新页面时都会显示随机背景图像,并且我在字符串连接方面遇到了一些麻烦。

$display .= "<p class=\"ey-image-quote\" style\"background-image:url('".$img."')\">" . $this->quote . "</p>";

This returns a url without slashes (replaced by spaces) and i have not found a viable solution yet. 这将返回一个没有斜杠的URL(由空格代替),我还没有找到可行的解决方案。 Is there any way to achieve this in php? 有什么办法可以在php中实现呢?

$display .= "<p class=\"ey-image-quote\" style=\"background-image:url('".$img."')\">" . $this->quote . "</p>";

你忘了=风格

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

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