When programming in C, I often get the advice to turn on many or all warnings and not ignore warnings.
Does the same hold in PHP, should I enable all warnings in the PHP log?
|
When programming in C, I often get the advice to turn on many or all warnings and not ignore warnings. Does the same hold in PHP, should I enable all warnings in the PHP log? |
|||
|
|
|
Default log level for PHP excludes notices, ie. it's If you're working only with your code, then you're much better off setting it to However, if you're working with third party code, turning on all notices ( |
|||||||||||
|
|
Yes, of course. Why on Earth would you not want to automatically catch as many problems and potential issues as you can, especially when starting from scratch? |
|||||||||||
|
|
Enabling warnings in PHP gives an extra edge for a programer to know where his coding is going wrong on which page , line etc... imagine manually checking 1000's of line to catch an error, if you have included multiple files, then you need to check as many as you have got. Therefore, it is better practise to enable it for a programer point of view!. |
|||
|
|
|
In development phase of project I prefer to have: "E_ALL | E_STRICT" with display_errors turned on too so I can get all possible warning/erors/notices and so on. Just a simple lapsus in $user vs $usr can create a whole bunch of problems later and PHP without this setting will not create build problems but will generate broken bussiness logic. In production mode it is best to have them turned on too but disabled display_errors flag. You can create your own custom error handler so logs can be written there or use for instance Apaches error log to find them (custom ones are better since you can write down more context that you need) |
|||
|
|