PHP의 사전 정의된 예외

伊谢尔伦
풀어 주다: 2016-11-22 11:07:11
원래의
988명이 탐색했습니다.

1.Exception

(PHP 5 >= 5.1.0)

소개

Exception은 모든 예외의 기본 클래스입니다.

메서드

Exception::__construct — 예외 생성자

Exception::getMessage — 예외 메시지 내용 가져오기

Exception::getPrevious — 예외 체인 반환

Exception::getCode의 이전 예외 — 예외 코드 가져오기

Exception::getFile — 예외가 발생한 프로그램 파일 이름 가져오기

Exception::getLine — 파일에서 비정상적인 코드의 발생 줄 번호를 가져옵니다.

Exception::getTrace — 예외 추적 정보 가져오기

Exception::getTraceAsString — 문자열 형식 예외 추적 정보 가져오기

예외 ::__toString — 예외 객체를 문자열로 변환

Exception::__clone — 예외 복제

2.ErrorException

(PHP 5 >= 5.1.0)

소개

오류 예외.

예 #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 &#39;ErrorException&#39; with message &#39;Wrong parameter count for strpos()&#39; in /home/bjori/tmp/ex.php:8
Stack trace:
#0 [internal function]: exception_error_handler(2, &#39;Wrong parameter...&#39;, &#39;/home/bjori/php...&#39;, 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.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!