I was wondering if a site which has thousands of simple notice warnings about undefined variable will be suffering by degraded performance even if it is not logged in either a file or displayed?
I know that the I/O performance will be degraded if it needs to log all the notice warnings but will it still be some sort of degrading performance if the log is off?
Does PHP engine still need to process these notices in someway?
Thx in advance
07-25-2007, 10:21 AM
You can turn error_reporting off. I still think it goes into a log somewhere though if a site has that many notice warnings/errors then it needs to be fixed.
I know you can set it to OFF, but does the PHP Engine still process all the errors in someway? If you turn it off it does not display them or log them to a file, but does it still get proceed or is it like the errors never existed (coding is done the way the engine wants it)?
07-25-2007, 03:02 PM
The error reporting just determines what is output to the browser. Turning it off just stops the last step in the error detection logic of adding the message to output content.
Turning off logging to the log file and/or suppressing errors using an @ would be a bad idea as you would then have no idea why your code is not working and since you are discussing code that has numerous notice and warnings, it is a pretty good bet that the code itself has no error checking of things like failed function calls...
Short answer, yes there is a performance hit, because PHP is trying to figure out what you are trying to do with the code. For something like an undefined variable, php must search through all the defined variables trying to find the name you are referencing and when it gets to the end of the list without finding a match, it defaults to the error processing code that figures out what to do. The error processing code figures out what to do in the code for the current reference to the undefined variable (this is repeated for each reference to the same variable), figures out if error logging is enabled and writes the error to the log file, and figures out the current error reporting level and outputs the message to the browser if needed.
It is always best to write code that does not normally cause any notice/warning messages to be generated.
Edit: If your code is written to be as bullet-proof as possible and has error checking, error reporting, and error recovery logic and then if a notice/warning is logged it would indicate that an un-expected condition occurred that your code was not testing for. The notice/warning would let you know of a weak area in your logic where you need to put in some additional checking logic. Generation of notice/warnings should be the exception, not the norm. If you have code that is generating a long list of these, fix them, don't try to suppress them after the fact.
Then it seems that there is nothing to do then fix all the notice issues... :mad:
That's the thx you get for taking over somebodies ****ty code... :D
Thack u all for all your help!