国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

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

PHP基礎之預定義異常

瀏覽:116日期: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
相關文章:
主站蜘蛛池模板: 竹山县| 锡林浩特市| 枞阳县| 高密市| 广水市| 卓尼县| 雅江县| 汉寿县| 社旗县| 喀什市| 鄂伦春自治旗| 涡阳县| 鹰潭市| 抚远县| 延津县| 沙湾县| 富蕴县| 双流县| 常宁市| 仁布县| 辰溪县| 石屏县| 雷州市| 盐源县| 正阳县| 调兵山市| 鱼台县| 郸城县| 澄城县| 寻甸| 密山市| 兴安盟| 玛曲县| 芦溪县| 竹山县| 波密县| 隆子县| 阳西县| 襄垣县| 桑日县| 凌海市|