php - 忽略错误的好主意?

标签 php error-reporting

<分区>

我发现在我的系统上“error_reporting”被关闭了。所以我打开它 (E_ALL),现在我有很多错误。

如果你对我的错误感兴趣:

Notice: Undefined index: page in …path/file.php on line 22
Notice: Undefined offset: 1 in …path/file.php on line 49
Notice: Undefined offset: 2 in …path/file.php on line 57
Notice: Undefined offset: 3 in …path/file.php on line 58
Notice: Undefined variable: out in …path/file.php on line 85
Notice: Undefined variable: out in …path/file.php on line 109
Notice: Use of undefined constant M_DESCRIPTION - assumed 'M_DESCRIPTION' in …path/file.php on line 181
Notice: Use of undefined constant GA_TRACKER - assumed 'GA_TRACKER' in …path/file.php on line 291
Notice: A session had already been started - ignoring session_start() in …path/file.php on line 12
Notice: Undefined variable: attributes in …path/file.php on line 86
Notice: Undefined variable: li in …path/file.php on line 129
Notice: Undefined index: breakafterlabel in …path/file.php on line 175
Notice: Undefined index: afterlabel in …path/file.php on line 167
Notice: Undefined index: attributes in …path/file.php on line 188
Notice: Undefined index: value in …path/file.php on line 191
Notice: Undefined index: for in …path/file.php on line 163
Notice: Undefined index: attributes in …path/file.php on line 249
Notice: Undefined index: value in …path/file.php on line 299
Notice: Undefined variable: out in …path/file.php on line 109
Notice: Undefined offset: 0 in …path/file.php on line 418
Notice: Undefined index: maxlength in …path/file.php on line 368
Notice: Undefined index: accept in …path/file.php on line 372
Notice: Undefined variable: out in …path/file.php on line 93
Notice: Undefined index: accept in …path/file.php on line 378
Notice: Undefined index: title in …path/file.php on line 379
Notice: Undefined index: accept in …path/file.php on line 402
Notice: Undefined index: fp in …path/file.php on line 624
Notice: Undefined variable: alert_msg in …path/file.php on line 246
Notice: Undefined variable: returner in …path/file.php on line 87
Notice: Undefined index: body in …path/file.php on line 309
Notice: Undefined variable: out in …path/file.php on line 81
Notice: Undefined variable: defaults in …path/file.php on line 121

起初我想“哦,你最好再把它关掉”,但我不确定后果!

所以非常简单的问题是:忽略所有错误是否重要?

最佳答案

在开发环境中,最好使用 error_reporting(E_ALL),这样您也可以看到通知。这会鼓励您拥有更高的编码标准。

运行实时站点时,您必须关闭 display_errors,但记录您的错误(就像您正在做的那样)。

这样,您将只会看到有意义的错误,而不仅仅是“注意:未定义...”。如果网站已经完成,您应该花一点时间重构您的代码,从长远来看是值得的。

关于php - 忽略错误的好主意?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14396847/

相关文章:

php - 是否可以在服务器端运行 jQuery?

php - mysqli_fetch_assoc()需要参数/调用成员函数bind_param()错误。如何获取并修复实际的mysql错误?

php - mysqli_fetch_assoc()需要参数/调用成员函数bind_param()错误。如何获取并修复实际的mysql错误?

php - 如何在不递增的情况下按字母顺序获取下一个字母? (php)

php - 是否可以从 SQL Server 创建文本格式的列表,然后由 PHP Cron 作业处理?

php - 谁用 crypt() 创建了一个认证系统

php - National Instruments USB 6008 和 Linux

php - 为什么我没有收到任何错误?

php - mysqli_fetch_assoc()需要参数/调用成员函数bind_param()错误。如何获取并修复实际的mysql错误?

php - mysqli_fetch_assoc()需要参数/调用成员函数bind_param()错误。如何获取并修复实际的mysql错误?