エラーをスローするこの方法を使用する必要があります:
if (isset($this->dbfields[$var])) {
return $this->dbfields[$var];
} else {
throw new FieldNotFoundException($var);
}
またはこのスタイル:
try {
return $this->dbfields[$var];
} catch (Exception $e) {
throw new FieldNotFoundException($var);
}
...またはまったく別のものですか?
コードの簡単な説明: $this->dbfields
は配列です。isset()
変数が設定されているかどうか、この場合は配列要素が存在するかどうかをチェックします。