Home > PHP Framework > Swoole > What does swoole fatal error mean?

What does swoole fatal error mean?

藏色散人
Release: 2020-04-09 10:41:32
Original
3251 people have browsed it

What does swoole fatal error mean?

swoole What is the fatal error?

Capture fatal errors during Server runtime

Once a fatal error occurs during Server runtime, the client connection will not be able to receive a response. For example, a web server should send an HTTP 500 error message to the client if there is a fatal error.

In PHP, fatal errors can be captured through register_shutdown_function error_get_last 2 functions and the error information is sent to the client connection. The specific code examples are as follows:

register_shutdown_function('handleFatal');
function handleFatal()
{
    $error = error_get_last();
    switch ($error['type'] ?? null) {
        case E_ERROR :
        case E_PARSE :
        case E_CORE_ERROR :
        case E_COMPILE_ERROR :
            $message = $error['message'] . PHP_EOL;
            if (isset($_SERVER['REQUEST_URI'])) {
                $message .= '[QUERY] ' . $_SERVER['REQUEST_URI'];
            }
            // log or send:
            // error_log($message);
            // $server->send($fd, $message);
            break;
    }
}
Copy after login

The above is the detailed content of What does swoole fatal error mean?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template