A problem about source code in thinkphp5

1, question

when I was in the source code of tp5.1, when I saw registration errors and exception handling mechanism, I saw a piece of code in error.php that I didn"t quite understand

.
public static function appError($errno, $errstr, $errfile = "", $errline = 0)
    {
        $exception = new ErrorException($errno, $errstr, $errfile, $errline);
        if (error_reporting() & $errno) {
            //  think\exception\ErrorException
            throw $exception;
        }

        self::getExceptionHandler()->report($exception);
    }

this is the handler of error, and
I particularly don"t understand the paragraph if (error_reporting () & $errno) .

What is the significance of

this bit operation here?

May.22,2021

the function of the whole code is to convert the error you are concerned about into exception handling, otherwise, if an error occurs, it will follow the error handling process: log, and in the exception handling process, in addition to logging, it will also send the corresponding response to the client. The bit operation is used to determine whether the error is the error you are concerned about


if an error is displayed ( error_reporting () > 0 ) and an error occurs ( $errno > 0 ), throw an exception
otherwise only record the error

Menu