<?php
include_once 'forecastVo.php';
include_once 'BaseVo.php';
$count=0;
$json_url = file_get_contents(
'http://maps.google.com/maps/api/geocode/json' .
'?address='jaipur'&sensor=false'); //line 9
if($json_url){
$obj = json_decode($json_url,true);
$obj2= $obj['results'];
}
?>
我收到错误:
解析错误:语法错误,意外的 T_STRING
/home/a4101275/public_html/index.php 第 9 行
第 9 行是我使用的地方file_get_contents
.
该错误是什么意思以及如何修复它?
您必须正确使用转义字符。不能有单引号 ('
) 在单引号封装的字符串内。它打破了它。为了继续字符串并使 PHP 按字面解释内部单引号,您必须使用以下命令对其进行转义\
.
$json_url = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=\'jaipur\'&sensor=false');
或者您可以使用替代字符串封装器,双引号 ("
).
$json_url = file_get_contents("http://maps.google.com/maps/api/geocode/json?address='jaipur'&sensor=false");
备查,Parse error: syntax error, unexpected T_STRING
通常意味着该线上某处的字符串有问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)