Php 多域脚本的API密钥,google map V2
有人能检查一下为什么我下面的脚本不起作用吗Php 多域脚本的API密钥,google map V2,php,google-maps-api-2,Php,Google Maps Api 2,有人能检查一下为什么我下面的脚本不起作用吗 <script src="http://maps.google.com/maps?file=api&v=2.x&key= <?php $this->googleMapsApiKey = $this->getValueFromDB("google", "googleMapsApiKey"); if ($_SERVER['HTTP_HOST']=='www.ABC.info
<script src="http://maps.google.com/maps?file=api&v=2.x&key=
<?php
$this->googleMapsApiKey = $this->getValueFromDB("google", "googleMapsApiKey");
if ($_SERVER['HTTP_HOST']=='www.ABC.info') {
$this->googleMapsApiKey = "Googlemap-keys";
} elseif ($_SERVER['HTTP_HOST']=='www.CBA.com') {
$this->googleMapsApiKey = "Googlemap-keys";
}
?>" type="text/javascript"></script>
我完全同意Wrikken的观点,在这个过程中,您似乎没有响应变量。也许这种方法有助于:
<?php
print '<script src="http://maps.google.com/maps?file=api&v=2.x&key=';
$this->googleMapsApiKey = $this->getValueFromDB("google", "googleMapsApiKey");
switch ($_SERVER['HTTP_HOST'])
{
//Specific for a domain, but I think that the default handles it against your DB automatically
//case 'www.ABC.info' : $this->googleMapsApiKey = "Googlemap-keys";
// break;
//Same here
// case 'www.CBA.com': $this->googleMapsApiKey = "Googlemap-keys";
// break;
default: $this->googleMapsApiKey = "Googlemap-keys";
}
echo "$this->googleMapsApiKey type=\"text/javascript\"></script>";
?>
您可以避免整个问题:Maps API密钥现在支持多个域(并且您可以随时编辑授权域)。有关更多详细信息,请参阅。echo$this->googleMapsApiKey代码>可能在PHP脚本的末尾?HTML中的键现在为空。