可能重复:
“call to undefined function” error when calling class method
我知道这看起来很愚蠢,但我对php有点新意,我被困住了。我试图谷歌这个,但我找不到任何东西。
我在这里调用了未定义的函数错误“$ relatedMovies = getRelatedMovies($ search);”我不知道为什么
class Page{
private $currentMovie;//the displaying movie of the page
private $relatedTitle;//related (maybe search) title
private $relatedMovies;//an array of movie titles and images
public function __construct(){
//other stuff here
$relatedMovies = getRelatedMovies($search);/******call to undefined function*********/
}
/**
* returns an array of related movie titles
*/
private function getRelatedMovies($title){
$relatedMovies = array();
//do stuff here
return $relatedMovies.length > 0 ? $relatedMovies : null;
}
}
$page = new Page();