Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good idea to ignore errors? [closed]

I found out that on my system "error_reporting" was turned off. So I turned it on (E_ALL) and now I have quite a lot errors.

if you're interested in my mistakes:

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

First I thought "Oh you better turn it off again", but I'm not sure about the consequences!

So the very simple question is: Does it matter if I ignore all the errors or not?

like image 388
John Doe Smith Avatar asked Feb 18 '23 19:02

John Doe Smith


1 Answers

In a development environment it's best to work with error_reporting(E_ALL), so you can see notices as well. This encourages you to have a higher coding standard.

When running a live site, you MUST have display_errors off, but log your errors (just like you're doing).

This way, you will only see errors that have meaning, and not only "Notice: Undefined ...". If the website is already done, you should spend a bit of time refactoring your code, the long-term benefits will be worth it.

like image 83
Vlad Preda Avatar answered Feb 28 '23 07:02

Vlad Preda