【发布时间】:2014-08-21 21:25:32
【问题描述】:
是的,在我将所有内容转移到我的主机之前,这一切都运行良好,现在这不起作用
这段代码有什么问题,我需要在我的主机上配置一些东西吗?
这里是 php,它使用 google maps api
function getlatlang($location)
{
$geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address='. urlencode($location) .'&sensor=false');
$output= json_decode($geocode);
return $output->results[0]->geometry->location;
}
$objlocation = getlatlang($postcode);
$latitude = $objlocation->lat;
$longitude = $objlocation->lng;
我还打开了错误报告 E_ALL,但没有显示任何内容,所以我尝试了 -1,它给出了以下错误。但是我在本地主机上从来没有遇到过这些错误
Notice: Undefined offset: 0 in /websites/123reg/LinuxPackage22/fa/gs/an/fagsandbooze.com/public_html/test.php on line 14
Notice: Trying to get property of non-object in /websites/123reg/LinuxPackage22/fa/gs/an/fagsandbooze.com/public_html/test.php on line 14
Notice: Trying to get property of non-object in /websites/123reg/LinuxPackage22/fa/gs/an/fagsandbooze.com/public_html/test.php on line 14
Notice: Trying to get property of non-object in /websites/123reg/LinuxPackage22/fa/gs/an/fagsandbooze.com/public_html/test.php on line 18
Notice: Trying to get property of non-object in /websites/123reg/LinuxPackage22/fa/gs/an/fagsandbooze.com/public_html/test.php on line 19
【问题讨论】:
-
完整的错误检查和显示在 ?还有
var_dump($output) -
将 error_reporting 转为 E_ALL 并查看是否有任何错误。对来自 file_get_contents 的响应进行 var_dump 以查看您是否获得了预期的响应。
-
就是我所说的 :-)\
-
看看,我编辑了帖子:)
-
返回行是 14 ?所以转储输出的值,它不是你认为的那样
标签: php google-maps localhost geocoding