如果我有2个php变量$ latitude和$ longitude,我如何将它们传递给url如果纬度12和经度为15的URL会在图像url中使用php变量
<img border="0" src="http://maps.googleapis.com/maps/api/staticmap?center=12,15&zoom=16"
我试过单独呼应的网址元件,但它似乎没有工作
如果我有2个php变量$ latitude和$ longitude,我如何将它们传递给url如果纬度12和经度为15的URL会在图像url中使用php变量
<img border="0" src="http://maps.googleapis.com/maps/api/staticmap?center=12,15&zoom=16"
我试过单独呼应的网址元件,但它似乎没有工作
$lat = 12;
$long = 15;
$img = "<img border='0' src='http://maps.googleapis.com/maps/api/staticmap?center=$lat,$long&zoom=16' />"
echo $img;
你也可以这样做:
$img = "<img border='0' src='http://maps.googleapis.com/maps/api/staticmap?center=". $lat. ",". $long."&zoom=16' />"
这应该工作:
<img border="0" src="http://maps.googleapis.com/maps/api/staticmap?center=<?php echo $latitude; ?>,<?php echo $longitude; ?>&zoom=16"
我不知道你已经尝试过什么,但这个会做
$url = "http://maps.googleapis.com/maps/api/staticmap?center=" . $lat . "," . $long ."&zoom=16";
Echo $url;
尝试:
<img border="0" src="http://maps.googleapis.com/maps/api/staticmap?center=<?=$latitude?>,<?=$longitude?>&zoom=16"/>
<?=$latitude?>
,只有很短的回声,是一样的做<?php echo $latitude; ?>
Hiya, this may well answer the question... but don't forget that total n00bs will likely somebody come and find this question/answer and will wonder why this works... can you please give some explanation for why/how your solution works? :) –
okay, it's =$latitude?>附近单引号,只是一个短回声,与<?php echo $ latitude?>相同 – abfurlan
使其看起来更简单。只是回应整个事情。
<?php
$latitude = 12 ;
$longitude = 15 ;
echo "<img border='0' src='http://maps.googleapis.com/maps/api/staticmap?center=$latitude,$longitude&zoom=16'>" ;
?>
您需要在 mesutozer
Or the other way around. – Jonast92