error_log
发送错误信息到某个地方
error_log
此函数自 PHP 4 版本起便可使用。
error_log() 函数用于将错误信息发送到指定的文件、邮件或系统日志。它主要用于调试或记录应用程序的错误信息,便于开发者检查和分析错误。
error_log(message, message_type, destination, headers);
此函数在成功时返回 true,失败时返回 false。
1. 将错误信息写入 PHP 错误日志
error_log("This is an error message.");
2. 通过电子邮件发送错误信息
error_log("This is an error message.", 1, "[email protected]");
3. 将错误信息追加到文件
error_log("This is an error message.", 3, "/var/log/php_errors.log");