0

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
     });
});

値ではなく変数名を取得しています...

4

2 に答える 2

0

これを試して:

$(document).ready(function(){
     $(document).bgStretcher({
           images: <?php echo $arrPath["bg"]; ?>, imageWidth: <?php echo $w; ?>, imageHeight: <?php echo $h; ?>
     });
});
于 2011-12-19T02:31:05.267 に答える
0

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?>
     });
});
于 2011-12-19T02:45:11.603 に答える