Hello. I have a question regarding using error_reporting(). I was under the assumption that it's best to use error_reporting(E_ALL) when you're developing your site, but to switch it to error_reporting(0) when your site goes live.

However, I was just reading an article (http://phpsec.org/projects/guide/1.html ), and it said that the preferred method is to use error_reporting(E_ALL) for both development and production, but to change display_errors from on to off when you go into production. Any thoughts on this? I'm curious as to what others use. Thanks!

    yes it is better to keep error_reporting(E_ALL) and to change display_errors from on to off when you go into production. Also remember to enable log_errors and to give a valid file path in error_log so that even if you have switched off error display ... the error info will still be written to the specified file. This will let you check for any bugs in you system later on and the user will not see any of the error messages.

      Cool. Thanks! That looks like the way I'll be going. I'll be turning on error reporting in all php files (E_ALL), set display_errors to Off for when site goes live, set log_errors to On for when site goes live, and also set the path for error_log. Thanks again!

        just do a debug.php
        and type in it:
        error_reporting(E_ALL);
        ini_set('display_errors', '1');

        and then whenever you find a problem type:
        include("debug.php"); // on top of your page.

        And perhaps do a live.php when you put it online

          Thanks. How do you set the path info for where the error log file is written to?

            Cool. I just read the link and it said that using set_ini() to set the value of display_errors() might not work all the time. I think I'll just have the master values set to what I want them to be. That should be enough, right? That way, I don't have to worry about making all these function calls at the beginning of every PHP script.

            Additionally, I noticed (using phpinfo()) that the master value of error_reporting is set to 2039. Is this the equivalent of it being set to E_ALL?

              4 days later

              Cool. Thanks. Is there a list somewhere of these numerical equivalents?

                duh.. i should've checked there first. thanks!

                  Write a Reply...