所以我正在尝试这个代码并不断收到这个错误
致命错误:未捕获的错误:函数名称必须是 /var/www/public_html/admin/get-features.php:10 中的字符串 堆栈跟踪:#0 {main} 抛出在 /var/www/public_html/admin/get-第 10 行的 features.php
你可以在下面看到我的代码
我试过谷歌搜索并尝试我在谷歌上找到的不同东西,但似乎无法让它工作
<?php
$conn = new PDO('mysql:host=;dbname=;charset=utf8','','',array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
$rs = $conn->query('SELECT *, x AS x, y AS y FROM GPS');
if (!$rs) { /* handle error */ }
$geojson = array ('type' => 'FeatureCollection','features' => array());
while ($row = $rs->fetch(PDO::FETCH_ASSOC)) {
$properties = $row;
unset($properties['x']);
unset($properties['y']);
$array_push($geojson['features'], array(
'type' => 'Feature',
'geometry' => array(
'type' => 'Point',
'coordinates' => array($row['x'],$row['y']) ),
'properties' => $properties )
);
}
header('Content-Type: text/json');
echo JSON_encode($geojson);
?>
长风秋雁