Php CSS背景不显示

Php CSS背景不显示,php,html,Php,Html,我有两个脚本,第二个脚本链接到第一个脚本,所以请看两个脚本。我的第一个脚本: theme.php 当我运行status.php时,一切看起来都很好,但唯一的问题是没有显示背景,它只显示一个白色页面和内容本身。背景应该是从天使拍图片随机bg每次刷新。我猜我在这一部分犯了一个错误: body { -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover;

我有两个脚本,第二个脚本链接到第一个脚本,所以请看两个脚本。我的第一个脚本: theme.php

当我运行status.php时,一切看起来都很好,但唯一的问题是没有显示背景,它只显示一个白色页面和内容本身。背景应该是从天使拍图片随机bg每次刷新。我猜我在这一部分犯了一个错误:

body {
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    background-image: url('.$bgUrl.');
    background-repeat: no-repeat;
    margin: auto;
    width: auto;
    height: auto;
    display: table;
    text-align:center;
}
但我就是想不出我的错误。如何在status.php中显示背景?我真的为冗长的脚本感到抱歉,我现在真的处于极限

更新 正如一些人所建议的,我在我的浏览器中查看了status.php的源代码,得到了以下结果:

body {
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    background-image: url();
    background-repeat: no-repeat;
    margin: auto;
    width: auto;
    height: auto;
    display: table;
    text-align:center;
}

背景图片:url;没有显示任何东西,救命

在第一段代码中有背景图像:url'.$bgUrl';第三位是背景图像:url“$selectedBg”。-是哪一个

此外,您可能还应该将变量传递到函数中,以便您的代码如下所示:

编辑:

然后在调用函数时,将变量传递给它:

css($bgUrl);

添加全局$bgUrl;在函数的开头,css

查看源代码是$selectedBg有效的图像\location请在浏览器中查看页面的源代码,要检查它是否正在打印您认为它正在打印的内容,您也可以控制台。记录$bgUrl以查看它是否是图像的有效路径。将HTML直接与其中一个背景一起测试它是否有效。伙计们,我更新了我的帖子,请再次查看。变量$bgUrl超出css函数的作用域。很抱歉,它是$bgUrl。我可以这样做来显示图像路径吗$bgUrl=echo bgchange;
body {
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    background-image: url();
    background-repeat: no-repeat;
    margin: auto;
    width: auto;
    height: auto;
    display: table;
    text-align:center;
}
function css($bgUrl){
  /* CSS code here*/
  echo $bgUrl;
}
css($bgUrl);