下列錯誤顯示爲下面給出的代碼PROPERT:試圖讓非對象錯誤
未定義的屬性:stdClass的:: $持續時間在C:\ WAMP \ WWW \ TEMP \ yy.php
試圖讓非對象的屬性在C:\ WAMP \ WWW \ TEMP \ yy.php
如何解決?
$q = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=$a,$b&destinations=$c,$d&mode=driving&sensor=false";
$json = file_get_contents($q);
$details = json_decode($json);
$d=$details->rows[0]->elements[0]->duration->text;
做的'$ json'一個'var_dump',以確保它是有效的JSON。此外,執行'$ details'的'var_dump'來確保它是一個對象。 –
你有什麼在這些('起源= $ a,$ b&destinations = $ c,$ d')變量? –