我需要能夠捕獲錯誤。我有以下代碼PHP捕獲錯誤
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
是的,如果檢查其所失敗返回一個動態的錯誤消息。
UPDATE
我目前的代碼,像這樣
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
}
但想不同的地方TI沒有做檢查的一行,並更改消息。
注意@jack在此更新之前已經發布了他的答案。
如果這是一個函數,你肯定可以返回一個字符串包含錯誤信息,並檢查是否返回值=== TRUE,否則假定存在錯誤情況和返回值錯誤。 –
是的,這是一個類方法 –
是否所有的數據被驗證存儲在類成員,可以迭代? –