在 catch (Exception $e) 的情况下,以下代码在 $lat = $track[0] 行失败。如何解决?
$track = getPositionalTrack();
$lat = $track[0];
$lon = $track[1];
function getPositionalTrack()
{
$track = array();
$url = "https://...";
try
{
$result = file_get_contents($url);
$obj = json_decode($result, true);
$lat = $obj["lat"];
$lon = $obj["lon"];
$track[0] = $lat;
$track[1] = $lon;
}
catch (Exception $e)
{
die('ERROR: ' . $e->getMessage());
}
return $track;
}