Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've been using and configuring PHP, but now I'm stuck in a weird problem, so I am going to ask you guys for help.

I don't want to see Deprecation Warnings and Notices in a production server, however I would like to see other error messages, such as Syntax Errors for example.

I'm running PHP 5.3.3-1ubuntu9.3 with Suhosin-Patch on Ubuntu 10.10

In my /etc/php5/apache2/php.ini I've the following line:

error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE

I've restarted the webserver. In the virtual host configuration there is no php_admin_value messing with this configuration, in the folder there isn't any .htaccess file.

Nevertheless Deprecation Warnings and Notices are still shown.

Anyone can help? Thank you in advance!

share|improve this question

2 Answers 2

Set the variable in /etc/php5/apache2/php.ini to

error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR

this will only show errors.

share|improve this answer
    
Yup, thank you.. however I think I understood the problem. error_reporting() was called in the website. I didn't think about that because I didn't write the website. Also my line works to remove notice and deprections, unless redefined at a lower level of course. Sorry for not realizing this before. –  stivlo Apr 25 '11 at 17:34
1  
@stivlo you need to accept this answer :-) –  Oneiroi Apr 25 '11 at 20:35
    
I'm not accepting this answer because, it didn't solve my problem. My problem was that I forgot one level of configuration (in the source file), besides those I listed. My configuration showing error and warnings is what I wanted, only it was overwritten by lower level. –  stivlo Apr 26 '11 at 16:30
    
@stivlo then you should post a reply with full detail and accept that ... incase anyone with the same issue comes across this question. –  Oneiroi May 3 '11 at 9:03
    
@Oneroi, I replied to my own question in detail, explaining the precedence of settings that I'm aware of in PHP.. thank you for the suggestion. –  stivlo May 3 '11 at 14:23
up vote 4 down vote accepted

First of all I want to thank binfalse for answering this question, however my problem was not solved with his suggestion and notices continued to show.

This is because PHP has several places where configuration can be set. While I had an idea of the precedence of those settings, I decided to test them experimentally to be sure of what I am going to say in this answer.

So here is a list of those places, from the more global to the more specific. Each setting lower in the list can override a setting that come before.

  1. The php.ini configuration file. In case of Ubuntu there are two of them, /etc/php5/apache2/php.ini is the one used for php apache module. It will have a global effect on all virtual hosts.

  2. The conf.d directory. Actually not all installations will have this modularized configuration, but in case of Ubuntu is located in /etc/php5/apache2/conf.d for the apache module. Any file added in this directory is going to be added to main php.ini configuration with higher precedence than php.ini. In other words any setting here will override settings in php.ini - I tested adding an error.ini. It will have a global effect on all vitual hosts.

  3. Apache virtual host configuration. Generally set in /etc/apache2/sites-available, every virtual host can have different settings. Inside the VirtualHost tag it's possible to include "php_value error_reporting ", where value is the numeric result of the boolean operations on the constants. In this configuration, in fact is not allowed to use the mnemonic constants but only a numeric value. It will affect only a single virtual host. It will override above settings.

  4. .htaccess. It's also possible to set configuration values and in particular the error_reporting setting also in .htaccess, with the same syntax described in 3. It will affect only the directory in which .htaccess is located and all subdirectories. It will override above settings, in this case is not necessary to restart apache.

  5. Source code. The last place where this setting can be altered is directly in the executed PHP source. If used, will override all previous settings, and that's exactly what I was facing. It can be set calling the function "error_reporting()" or with "ini_set("error_reporting", )". Compile errors could still show, because the script won't be executed in that case.

share|improve this answer
    
While I am at it, I wrote a blog post with a slightly modified version of this answer. –  stivlo May 3 '11 at 14:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.