kim*_*mbl 1 html php variables url background-image
我有一个关于使用 avariable作为 IconPath 来设置的问题background-image: url()
<div style="background-image: url($iconPath)"></div>
Run Code Online (Sandbox Code Playgroud)
我不知道如何使用变量设置背景图像的 url?
我尝试过"",,''\"
有人有想法吗?
PHP 是一种服务器端语言,因此如果您希望任何内容对 DOM(即 HTML)可见,您必须将其打印到 DOM。这是通过echo
<div style="background-image: url('<?php echo $iconPath ?>')"></div>
Run Code Online (Sandbox Code Playgroud)
如果需要打印任何变量值,只需打印echo它即可对 DOM 可见。