這是我的第一個問題PHP致命錯誤:調用一個成員函數getScore()一個非對象在
我有以下類
class ProDetection {
public function ProDetection () { }
public function detect($word) {
............
}
public function getScore() {
return $score;
}
}
class SaveDetection {
public function SaveDetection($words) {
$proDetection = new ProDetection();
for($i=0;$i<sizeof($words);$i++) {
$proDetection->detect($words[$i]);
}
}
public function getScore() {
return $this->proDetection->getScore();\\line 22
}
}
在其他PHP文件,我是嘗試調用SaveDetection getScore();
$konten = "xxxx xxxx xxx";
$save = new SaveDetection($konten);
print_r($save->getScore());
但我得到了一個錯誤信息
公告:未定義的屬性:SaveDetection :: $ proDetection在C:\ XAMPP \ htdocs中\ inovasi \上線SaveDetection.php 22
致命錯誤:調用一個成員函數getScore(c)中的非對象上:\ XAMPP \ htdocs中\ inovasi \上線SaveDetection.php 22
請需要您的幫助
Hi Sahal,非常感謝。是工作 – Ahmad 2011-06-16 05:02:26