「call_user_func」を使用せず、eval を使用せずにクラス内の関数を呼び出す方法はありますか?
これが私が尋ねる理由です:
「call_user_func」を使用すると、「$this not in context」エラーが発生します。
$this->id = $selectId['id'];
$file = 'score_' . $this->sid . '.php'; //the file with the class
if (@include_once($file)) { //including the file
$scoreClass = 'Score_' . $this->id;
call_user_func($scoreClass .'::selectData', $this->user_id);
}
この「コンテキスト内ではない」エラーを次のように関数を呼び出すことで解決できますが、私の名前は変数ではありません。
$this->id = $selectId['id'];
$file = 'score_' . $this->sid . '.php'; //the file with the class
if (@include_once($file)) { //including the file
$test = new Score_98673();
$test->selectData($this->user_id);
}