xiao Posted April 22, 2008 Share Posted April 22, 2008 I get some errors Undefined index: something in ... I know why I get them, I know how te remove them, but that would be a lot of unnecessary coding. If I set error reporting off, I won't get them anymore. Is it actualy a problem in any way if a variable doesn't exist yet when I check what's in it? Quote Link to comment Share on other sites More sharing options...
947740 Posted April 22, 2008 Share Posted April 22, 2008 I do not see why it is a problem. It seems rather pointless to turn the errors off, however, because you will not be able to see any errors that you may need to see. I know you know this, but you could just do a quick !isset($var) to check, and then carry out the code. That is not very much work to stop error messages. Quote Link to comment Share on other sites More sharing options...
xiao Posted April 22, 2008 Author Share Posted April 22, 2008 Yea, I know, but the problem is that I'd have to do an if(!isset($_SESSION['variable'])) && ...rest of checks... about 40 to 50 times more in my script just to get rid of some errors. I'm only planning to turn off error reporting when everything else works fine. Quote Link to comment Share on other sites More sharing options...
947740 Posted April 22, 2008 Share Posted April 22, 2008 That's fine. Just remember it is off when/if you make any changes... Quote Link to comment Share on other sites More sharing options...
xiao Posted April 22, 2008 Author Share Posted April 22, 2008 k thanks for your help Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 22, 2008 Share Posted April 22, 2008 The output of the warning message is just the last step in the error response code that php executes every time it encounters a variable that does not exist. If you turn off display_errors or set the error_reporting level to prevent the errors from being displayed, all the rest of the error response code still gets executed as php tries to figure out for each undefined variable what to do on that line of code. The error response code takes about 20-30 times longer to execute than an isset() statement. Code should not normally generate any warnings or notices. If you want your code to execute the quickest (important on a site getting 100's and 1000's of hits per second), take the time now to fix the problem that is causing the error response. Turning off display_errors on a live server is only a safeguard to prevent unexpected and uncaught conditions in your logic from exposing path and variable information. It is not for the purpose of disabling the output of errors your code generates every time it executes. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.