Home >Backend Development >PHP Problem >How php throws an error
How php throws an error: first debug the php error; then throw the php error through "set_error_handler('socketErrorLog');".
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!