如果我有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