I am working for a client who has some production sites on the machine i'm developing on. he's got display_errors turned off in php.ini for the overall web server setting. Is there some way I can over ride this setting but only for the subdirectory i'm developing in?

I know how to set error reporting to e_all but this doesn't help if there's a syntax error in the file I'm working on - the server just shows a blank page and I have no idea which line the syntax error is on.

    You could use php_flag in a .htaccess file...

    php_flag display_errors E_ALL & E_STRICT

    Or 1024 or 2048 or whatever the number is.

      Hm...well I got error reporting ON using this .htaccess file:

      php_flag display_errors On
      php_flag error_reporting E_ALL
      
      AuthType Basic
      AuthName "Restricted Area"
      AuthUserFile "/path/to/passwd"
      require valid-user
      

      I can easily do this in my code and get bazillions of notices:

      error_reporting(E_ALL);

      HOWEVER, a file with syntax errors that doesn't compile still results in a blank page. Like this, for instance has no output at all...not even a single character:

      <?
      $var = 'this file is broken...no semicolon at the end'
      $arar = 'blah'
      ?>
      

      Also, that second line in my htaccess seems to have no impact whatsoever on the amount of error reporting that goes on. if i remove the error_reporting() settings from my file and try to set error_reporting to E_ALL (or 6143, its numeric equivalent) in the htaccess file, it does absolutely nothing.

      The most important thing for me is to get line numbers when my script has a syntax error or other fatal error so i can find the problems.

        Well, the draw-back with .htaccess is that Apache has to allow the .htaccess to be used [AllowOverride] (in the Options line of the host in httpd.conf). If that's not enabled, the .htaccess will have no effect.

        Otherwise, there's really no other way unless you create your own php.ini and your PHP is set up to use the custom ini file (except adding error_reporting() to each script)....

        You could also log the errors (a php.ini option) so that even though they're not displayed, they're logged somewhere.

          Write a Reply...