我正在尝试在表单上显示错误消息,但只显示一条(总是最后一条)。我尝试使用 foreach 循环,但我不断收到无效参数错误。下面一一显示错误。代码在一个类中......
public $errorContainer = '';
// ------------------------------------------------------------
// ERROR MESSAGE PROCESSING
// ------------------------------------------------------------
private function responseMessage($respBool, $respMessage) {
$return['error'] = $respBool;
$return['msg'] = $respMessage;
if (isset($_POST['plAjax']) && $_POST['plAjax'] == true) {
echo json_encode($return);
} else {
$this->errorContainer = $respMessage;
}
}
以下总是给我每个参数错误的无效。
private function responseMessage($respBool, $respMessage) {
$return['error'] = $respBool;
$return['msg'] = $respMessage;
if (isset($_POST['plAjax']) && $_POST['plAjax'] == true) {
echo json_encode($return);
} else {
foreach ($respMessage as $value) {
$this->errorContainer = $value;
}
}
}
谢谢!