-1
我有這段代碼,我正在擴展一個類,但它說這個方法是未定義的。擴展類中未定義的方法
<?php
class api{
//$api_Key;
public function getURL($url){
return file_get_contents($url);
}
public function postURL($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
public function getJSON($json){
return json_decode($json);
}
}
class geo extends api{
public function getLocation(){
return json_decode(postURL("https://www.googleapis.com/geolocation/v1/geolocate?key=$key"));
}
}
class vote extends geo {
// Class properties and methods go here
}
?>
PHP文件,查看網頁
<?php
include("php/vote.php");
$geo = new geo();
echo $geo->getLocation();
?>
我收到此錯誤致命錯誤:
Call to undefined method geo::json_decode() in G:\wamp\www\voting\php\vote.php on line 22
我還沒有找到的東西,會幫我解決這個我有父母和孩子的課程正確或我認爲我是。 它擴展了這個類,所以我不確定它爲什麼沒有定義,任何幫助都很棒。
我仍然得到這個錯誤致命錯誤:調用G中未定義功能postURL() :\ wamp \ www \ voting \ php \ vote.php 22行 – Zach
編輯'$ this-> postURL' – AbraCadaver