久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

PHP基礎之預定義異常

瀏覽:111日期:2022-09-15 10:26:52
1.Exception

(PHP 5 >= 5.1.0)

簡介

Exception是所有異常的基類。

方法Exception::__construct — 異常構造函數Exception::getMessage — 獲取異常消息內容Exception::getPrevious — 返回異常鏈中的前一個異常Exception::getCode — 獲取異常代碼Exception::getFile — 獲取發生異常的程序文件名稱Exception::getLine — 獲取發生異常的代碼在文件中的行號Exception::getTrace — 獲取異常追蹤信息Exception::getTraceAsString — 獲取字符串類型的異常追蹤信息Exception::__toString — 將異常對象轉換為字符串Exception::__clone — 異常克隆2.ErrorException

(PHP 5 >= 5.1.0)

簡介

錯誤異常。

范例

Example #1 使用 set_error_handler()函數將錯誤信息托管至ErrorException

<?php function exception_error_handler($errno, $errstr, $errfile, $errline ) {throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } set_error_handler('exception_error_handler'); /* Trigger exception */ strpos();?>

以上例程的輸出類似于:

Fatal error: Uncaught exception ’ErrorException’ with message ’Wrong parameter count for strpos()’ in /home/bjori/tmp/ex.php:8Stack trace:#0 [internal function]: exception_error_handler(2, ’Wrong parameter...’, ’/home/bjori/php...’, 8, Array)#1 /home/bjori/php/cleandocs/test.php(8): strpos()#2 {main} thrown in /home/bjori/tmp/ex.php on line 8方法ErrorException::__construct — 異常構造函數ErrorException::getSeverity — 獲取異常的嚴重程度

標簽: PHP
相關文章:
主站蜘蛛池模板: 平安县| 沧源| 达日县| 长治市| 黔江区| 蒙阴县| 柞水县| 寿阳县| 黎平县| 广宗县| 禄劝| 桐梓县| 陕西省| 垦利县| 濉溪县| 阿鲁科尔沁旗| 治多县| 灵璧县| 七台河市| 大庆市| 民勤县| 泗水县| 体育| 揭东县| 浠水县| 琼结县| 兰溪市| 甘泉县| 卓尼县| 平遥县| 永年县| 安庆市| 扶余县| 保康县| 广汉市| 揭东县| 绥滨县| 宝应县| 木里| 新宾| 密云县|