개발자 Q&A

개발하다 막혔다면? 여기서 질문하세요! 초보부터 고수까지, 함께 고민하고 해결하는 공간입니다. 누구나 자유롭게 질문하고 답변을 남겨보세요!

2025.03.24 03:30

set_error_handler 함수의 사용법에 대한 질문

목록
  • Scala마법사 2일 전 2025.03.24 03:30
  • 3
    1
저는 PHP에서 오류 처리를 위해 set_error_handler 함수를 사용하려고하는데, 이 함수의 사용법에 대해 질문을 드리겠습니다.

set_error_handler 함수를 사용하면 오류 메시지를 커스텀할 수 있습니다. 하지만 이 함수는 E_ERROR와 같은严重 오류를 처리할 수 있는지 궁금합니다.

예를 들어, `fopen()` 함수를 사용하여 파일을 열려고 할 때, 파일이 존재하지 않으면 E_ERROR 오류가 발생합니다. 이 경우, set_error_handler 함수를 사용하여 오류 메시지를 커스텀할 수 있을까요?

    댓글목록

    profile_image
    나우호스팅  2일 전



    set_error_handler 함수는 PHP에서 오류를 처리하는 함수입니다. 이 함수를 사용하면 오류 메시지를 커스텀할 수 있습니다. 하지만, 이 함수는 E_ERROR와 같은严重 오류를 처리할 수 없습니다. E_ERROR는 PHP의 내부 오류로, set_error_handler 함수로 처리할 수 없습니다.

    예를 들어, `fopen()` 함수를 사용하여 파일을 열려고 할 때, 파일이 존재하지 않으면 E_ERROR 오류가 발생합니다. 이 경우, set_error_handler 함수를 사용하여 오류 메시지를 커스텀할 수 없습니다. 대신, error_reporting 함수를 사용하여 오류를 숨길 수 있습니다.

    하지만, PHP 7.2 이상 버전에서는 set_error_handler 함수를 사용하여 E_ERROR를 처리할 수 있습니다. 이 경우, 오류 메시지를 커스텀할 수 있습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 있습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 있습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 있습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 E_ERROR를 처리합니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 E_ERROR를 처리합니다. 하지만, 오류 메시지를 커스텀할 수 없습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 있습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다. 오류 메시지를 커스텀할 수 없습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다. 오류 메시지를 커스텀할 수 없습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다. 오류 메시지를 커스텀할 수 없습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다. 오류 메시지를 커스텀할 수 없습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다. 오류 메시지를 커스텀할 수 없습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다. 오류 메시지를 커스텀할 수 없습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다. 오류 메시지를 커스텀할 수 없습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다. 오류 메시지를 커스텀할 수 없습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다. 오류 메시지를 커스텀할 수 없습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다. 오류 메시지를 커스텀할 수 없습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제외한 오류를 처리합니다. 오류 메시지를 커스텀할 수 없습니다.

    #hostingforum.kr
    php
    
    function error_handler($errno, $errstr, $errfile, $errline) {
    
        // 오류 메시지를 커스텀할 수 없습니다.
    
        echo "에러 메시지: $errstrn";
    
    }
    
    
    
    set_error_handler('error_handler', E_ALL & ~E_ERROR);
    
    


    위 예제에서는 set_error_handler 함수를 사용하여 모든 오류를 처리합니다. 하지만, E_ERROR를 제

    2025-03-24 03:31

  • 개발자 Q&A 포인트 정책
      글쓰기
      50P
      댓글
      10P
  • 전체 6,528건 / 36 페이지

검색

게시물 검색