用法
bool trigger_error ( string $error_msg [, int $error_type] );
定義和用法
此函數用於觸發用戶錯誤條件,可與 內置 錯誤處理程序結合使用,或與已設置為新錯誤處理程序 (set_error_handler()) 的用戶定義函數一起使用。
參數
Sr.No | 參數及說明 |
---|---|
1 |
error_msg(Required) .它指定錯誤信息。長度限製為 1024 個字符。 |
2 |
error_types(Optional) 它指定此錯誤消息的錯誤類型。 可能的錯誤類型 -
|
返回值
如果指定了錯誤的 error_type,該函數返回 FALSE,否則返回 TRUE。
示例
以下是此函數的用法 -
<?php
if ($test<10) {
trigger_error("Number cannot be less than 10");
}
?>
這將產生以下結果 -
Number cannot be less than 10
相關用法
- PHP trigger_error()用法及代碼示例
- PHP trim()用法及代碼示例
- PHP trait_exists()用法及代碼示例
- PHP time()用法及代碼示例
- PHP token_get_all()用法及代碼示例
- PHP tan()用法及代碼示例
- PHP timezone_version_get()用法及代碼示例
- PHP timezone_name_get()用法及代碼示例
- PHP time_sleep_until( )用法及代碼示例
- PHP timezone_location_get()用法及代碼示例
- PHP tmpfile()用法及代碼示例
- PHP touch( )用法及代碼示例
- PHP timezone_transitions_get()用法及代碼示例
- PHP tmpfile( )用法及代碼示例
- PHP timezone_open()用法及代碼示例
- PHP timezone_identifiers_list()用法及代碼示例
- PHP time_nanosleep()用法及代碼示例
- PHP tanh( )用法及代碼示例
注:本文由純淨天空篩選整理自 PHP - Function trigger_error()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。