无法获取php变量来填充javascript代码
我尝试了下面的代码。
<?php
$destination="PAR";
$destination_name="Paris";
?>
<script async src="//www.travelpayouts.com/weedle/widget.js?
width=260px&marker=235474&host=search.jetradar.com&locale=en¤cy=
usd&powered_by=false&destination="<?php echo $destination ?
>";&destination_name="<?php echo $destination_name ?>";"
charset="UTF-8"></script>
结果未显示正确的目的地
答案 0 :(得分:0)
您不需要在GET参数周围加引号。
<?php
$destination="PAR";
$destination_name="Paris";
?>
<script async src="//www.travelpayouts.com/weedle/widget.js?
width=260px&marker=235474&host=search.jetradar.com&locale=en¤cy=
usd&powered_by=false&destination=<?php echo $destination ?>&destination_name=<?php echo $destination_name ?>"
charset="UTF-8"></script>