function error_message($type='', $ext='')
{ $a_msg = array(
'add_save' => '無法新增資料 (add_save)',
'display' => '無法列出資料 (display)',
'list_all' => '無法列出資料 (list_all)',
'list_page' => '無法列出資料 (list_page)',
'list_page_1' => '無法列出資料 (list_page_1)',
'list_page_2' => '無法列出資料 (list_page_2)',
'edit' => '無法編輯資料 (edit)',
'edit_save' => '無法修改資料 (edit_save)',
'delete' => '無法刪除資料 (delete)',
'default' => '有錯誤發生!' );
utility.php
db_pdo_sth 系列中使用 error_message()
自訂函式來統一處理錯誤訊息
$msg = isset($a_msg[$type]) ? $a_msg[$type] : $a_msg['default'];
if($type=='page')
{
$msg = '檔案資料『" . $ext . "』不存在';
}
$ret_str = '<h2>錯誤警告</h2>';
$ret_str .= '<p>' . $msg . '</p>';
return $ret_str;
}
utility.php