Php 使用bgStretcher变量

Php 使用bgStretcher变量,php,jquery,variables,setting,Php,Jquery,Variables,Setting,我刚刚开始php编程,我有一个问题: 有没有办法用变量设置bgStretcher图像的宽度和高度值 <?php $arrPath=array("bg" => "http://mydomain.com/myimage.jpg"); $w=1500; $h=800; ?> $(document).ready(function(){ $(document).bgStretcher({ images: $arrPath["bg"], imageWidt

我刚刚开始php编程,我有一个问题:

有没有办法用变量设置bgStretcher图像的宽度和高度值

<?php $arrPath=array("bg" => "http://mydomain.com/myimage.jpg"); $w=1500; $h=800; ?>

$(document).ready(function(){
     $(document).bgStretcher({
           images: $arrPath["bg"], imageWidth: $w, imageHeight: $h
     });
});

$(文档).ready(函数(){
$(文档).bg拉伸器({
图像:$arrPath[“bg”],图像宽度:$w,图像高度:$h
});
});
我得到的是变量名而不是它的值…

请尝试以下操作:

$(document).ready(function(){
     $(document).bgStretcher({
           images: <?php echo $arrPath["bg"]; ?>, imageWidth: <?php echo $w; ?>, imageHeight: <?php echo $h; ?>
     });
});
$(文档).ready(函数(){
$(文档).bg拉伸器({
图像:,图像宽度:,图像高度:
});
});

除了Indranil的答案之外,另一种节省空间的方法是:

<?php $arrPath=array("bg" => "http://mydomain.com/myimage.jpg"); $w=1500; $h=800; ?>

$(document).ready(function(){
     $(document).bgStretcher({
           images: <?=$arrPath["bg"]?>, imageWidth: <?=$w?>, imageHeight: <?=$h?>
     });
});

$(文档).ready(函数(){
$(文档).bg拉伸器({
图像:,图像宽度:,图像高度:
});
});

不客气。你应该勾选你想要的答案来标记这个问题的答案。帮助未来的搜索者:)我建议不要使用短标签只是为了节省一些空间。此外,如果您在共享服务器上,您的主机可能已将其关闭。