最好的方式来抑制生产服务器上的php错误 [英] Best way to suppress php errors on production servers

查看:97
本文介绍了最好的方式来抑制生产服务器上的php错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在浏览器中隐藏php错误的最佳方法是什么?

What is the best method of hiding php errors from being displayed on the browser?

是否使用以下内容:

ini_set("display_errors", 1);

任何最佳做法提示也将不胜感激!

Any best practice tips would be appreciated as well!

我正在记录错误,我只想确保将display_errors值设置为off(或0)不会阻止记录错误。

I am logging the errors, I just want to make sure that setting the display_errors value to off (or 0) will not prevent errors from being logged.

推荐答案

最好的方法当然是记录你的错误,而不是显示或忽略它们。

The best way is of course to log your errors instead of displaying or ignoring them.

这个例子会将错误记录到syslog而不是在浏览器中显示它们。

This example will log the errors to syslog instead of displaying them in the browser.

ini_set("display_errors", 0);
ini_set("log_errors", 1);

//Define where do you want the log to go, syslog or a file of your liking with
ini_set("error_log", "syslog"); // or ini_set("error_log", "/path/to/syslog/file");

这篇关于最好的方式来抑制生产服务器上的php错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆