Web Hosting Talk







View Full Version : php and error_reporting(0);


Shodaime
06-04-2006, 10:20 PM
Hello, I have many script files with error_reporting(0); and some of the files may even include/require files that already have error_reporting(0); even though it wouldn't show the error, would there be a problem if a certain file had error_reporting(0); twice?

laserlight
06-05-2006, 02:08 AM
No, there would be no problem. Even if there was, it wouldnt be reporting since error_reporting was set to 0 and the error couldnt possibly be fatal.

innova
06-05-2006, 11:28 AM
I have many script files with error_reporting(0);

Dont do that. Its bad practice.

Instead, have ONE file that you include in every script that sets up the environment, error control settings, etc. Then, in the future, when you want to test a new feature and debug, you only have to change the setting in ONE place. Smart eh?

Shodaime
06-05-2006, 12:10 PM
Thanks for both of the comments. Since I was in a rush I needed to include the error_reporting even if there were duplicates, I didn't have the time to check. Though I think in the future I'll try to just have it one file as you suggested innova :)

azizny
06-05-2006, 10:05 PM
It happened to me on my localhost a couple of times, the application just dies at a fatal error without reporting (even thou I make it all).

I think there is something with the php.ini you might have to change (never really bothered to).

Peace,

Burhan
06-06-2006, 01:58 AM
I think there is something with the php.ini you might have to change (never really bothered to).

Yeah, that would be the display_errors setting. If this is off, PHP will die silently :)

If you have control over your account, you can also use the auto_prepend directive and have apache attach a file on top of all php files that are served automatically. Then in this file you can setup your environment, reporting, constants, etc. If you do it this way, then you don't need an include/require statement.

Just like when you include files "normally" you should also keep in mind with the auto_prepend directive to not include any extra whilespaces before and after the <?php ?> tags, otherwise any headers you want to send will not get through -- this will affect your sessions as well as they will not be able to start.

Shodaime
06-06-2006, 02:02 AM
Thanks for the replies! Yeah I have control and access to the php.ini file, though I forgot about the display_errors option. I'll look into the apache method as well.