Home > Backend Development > PHP Problem > How php throws an error

How php throws an error

藏色散人
Release: 2023-03-06 19:46:01
Original
2572 people have browsed it

How php throws an error: first debug the php error; then throw the php error through "set_error_handler('socketErrorLog');".

How php throws an error

Recommended: "PHP Video Tutorial"

php throws error debugging method

//调试 php报错
    function socketErrorLog($errno, $errstr, $errfile, $errline)
    {
        $log = '[' . date('m d H:i:s') . '] errno:' . $errno . " errfile:$errfile line:$errline\n";
        $log .= "error: " . $errstr;
        $log .= "\n========================================================\n";
        file_put_contents(dirname(__FILE__).'/chaoyu.log', $log, FILE_APPEND);
    }
//抛出php错误
set_error_handler('socketErrorLog');
Copy after login

The above is the detailed content of How php throws an error. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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