niche Posted August 21, 2012 Share Posted August 21, 2012 (edited) According to the manual http://php.net/manua...r-reporting.php this turns off all error reporting presumably when I put this at the top of my script: error_reporting(0); However, I received an error (with filename ref) when I created a parse error with the above code at the top of my script.. How do I turn-off all error reporting in a script? Edited August 21, 2012 by niche Link to comment Share on other sites More sharing options...
justsomeguy Posted August 21, 2012 Share Posted August 21, 2012 That's how you turn of error reporting in a script. The problem is that if you have a parse error it never runs the script to turn off error reporting. Your other options are php.ini or htaccess. Turning off errors is not a great idea though. It's a much better idea to have it log errors and not display them, then at least you can review the log to look for problems. Link to comment Share on other sites More sharing options...
niche Posted August 21, 2012 Author Share Posted August 21, 2012 I changed display_errors to off, but the parse error persists. I'm mostly concerned with the display of the filename ref. How do I turn-off all error displays from the ini? I left the log_errors on. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 21, 2012 Share Posted August 21, 2012 The display_errors option controls if PHP sends error messages to the browser. Again, it doesn't do any good to set that in a file if you have a parse error (although you should never have deployed code which contains parse errors anyway). It's usually enough to set those options in a common include file. If you're deploying code that has parse errors then your job isn't done yet. This section describes how to change options: http://www.php.net/manual/en/configuration.php Link to comment Share on other sites More sharing options...
niche Posted August 21, 2012 Author Share Posted August 21, 2012 I know better than that. As I said in the OP, I [purposely] created the error [for testing]. Anyway, based on your #2, will parse error always display? If so, I'll need to create a different kind of error for testing. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 21, 2012 Share Posted August 21, 2012 PHP will use the settings in the ini file and any changes through htaccess while it is parsing the code. You can use the function trigger_error to cause your own runtime error. 1 Link to comment Share on other sites More sharing options...
niche Posted August 21, 2012 Author Share Posted August 21, 2012 Very cool jsg. I looked at my php_error.log for the first time too. Like Spock says, "For everything there is a first time.". I also suppressed errors from my .htaccess with this code: # supress php errorsphp_flag display_startup_errors offphp_flag display_errors offphp_flag html_errors offphp_value docref_root 0php_value docref_ext 0# enable PHP error loggingphp_flag log_errors onphp_value error_log "your path here" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now