-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