Home  >  Article  >  Backend Development  >  How php throws an error

How php throws an error

藏色散人
藏色散人Original
2020-10-29 09:02:232506browse

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');

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!

Statement:
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