0

While debugging my php script, I wanted to figure out how to get php to display all error messages, including notices. I found this thread which recommended these lines of code:

ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);

This worked really well. All of my pages were now displaying tons of helpful error messages. I went through everything and fixed it. However, when I deleted those lines of code, all of the notices that weren't there before I turned full reporting on are still there! I need to get them to go away now. How do I change the error reporting back to what it was before? Is there a way to do it without keeping some other code in the script? Preferably I want it to be like it was before--notices weren't reported and there was no code needed to specifically suppress them.

Community
  • 1
  • 1

1 Answers1

0

You used ini_set so now the ini files are set and will load these values. Try using ini_set to revert the values then you should be able to remove the lines of code.

Christian
  • 1,450
  • 9
  • 16
  • That's what I thought of too. I looked up the default values and put this code in the same place that I put the original code that turned on errors: `ini_set('display_errors',1); ini_set('display_startup_errors',0); error_reporting(NULL);` I loaded the page (which should have run these lines), restarted apache, and when I go back, all my other pages are still giving notices, as if this code only worked affected the script it is in, instead of affecting every page like the other code did. – Paul Keller Jul 22 '15 at 14:28
  • It still only affects the single page it's in instead of permanently reverting the configuration :( – Paul Keller Jul 22 '15 at 14:33
  • When I try to edit it in the terminal I get: `"php.ini" E212: Can't open file for writing` when I try to write and quit. – Paul Keller Jul 22 '15 at 14:48
  • Is this your server? Can you not chmod it? Or is this a windows server, can you open it if you kill apache process? – Christian Jul 22 '15 at 14:49
  • haha I just got it! I was using `sudo` to get into `/etc` but then I forget to type `sudo` again before `vim php.ini`. It works now! Thanks so much for your help. – Paul Keller Jul 22 '15 at 15:03