1

エラーをキャッチできる必要があります。次のコードがあります

if($call['status_id'] != '' && $call['datetime_required'] != '')
{
   //do stuff
}
else
{
  // tell them how it failed
}

ti が失敗したセクションを表示するにはどうすればよいですか。たとえば、動的なエラー メッセージを返すことができます。

return 'You did not fill in the field $errorField';

どこ

$errorField

失敗した if チェックです。

アップデート

私は現在そのようにコーディングしています

if($call['status_id'] != '')
{
    if ($call['datetime_required'] != '')
    {
      //do stuff
    }
    else
    {
      // tell them it failed due to the second condition
    }
}
else
{
   // tell them it failed due to the first condition
}

しかし、1 行でチェックを行い、ti が失敗した場所に応じてメッセージを変更したいと考えています。

@jack は、この更新の前にすでに回答を投稿していたことに注意してください。

4

2 に答える 2

2
if($call['status_id'] != '')
{
    if ($call['datetime_required'] != '')
        //do stuff
    }
    else
    {
        // tell them it failed due to the second condition
    }
}
else
{
  // tell them it failed due to the first condition
}
于 2013-10-03T15:43:33.130 に答える