Astarot
Astarot

Reputation: 73

.htaccess setting error_reporting with multiple PHP constants

I want set up own error_log without some error types over htaccess.

Like this: error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED

error_reporting = E_ALL(32767) & ~E_NOTICE(8) & ~E_WARNING(2) & ~E_DEPRECATED(8192)

So it should be php_value error_reporting 24565 (32767-8-2-8192=24565)

But I still get PHP Warning. What I'm doing wrong?

Here is a full code:

php_flag display_startup_errors off

php_flag display_errors off

php_flag html_errors off

php_flag log_errors on

php_value error_log /path/log/error_log.log

php_value error_reporting 24565

Upvotes: 0

Views: 1065

Answers (1)

Solonl
Solonl

Reputation: 2512

Although it is impossible to check the php code since it is not provided, here are a few things you can do.

Test the following script:

test.php

error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED);

var_dump(ini_get('error_reporting'));
trigger_error("Test", E_WARNING);

Run php test.php. The output should be: string(5) "24565", without any warning displayed.

Test if .htaccess values are accepted

Include this in your .htaccess file:

php_value error_reporting 24565

Now test if the value is accepted by PHP:

test.php

var_dump(ini_get('error_reporting'));
trigger_error("Test", E_WARNING);

Run with php test.php. It should output string(5) "24565", no warning displayed.

Check to see if error_reporting gets overwritten somewhere in your PHP code:

Look for the following functions:

ini_set('error_reporting', /* some value */);
error_reporting(/* some value */);

Upvotes: 2

Related Questions