Unable to turn off notice errors in php 5.3.2 – PHP

  php

Q(Question):

I recently migrated to PHP 5.3.2, and realized that I am unable to turn off notice errors in my site now. I went to php.ini, and in these lines:


; Common Values:
; E_ALL & ~E_NOTICE (Show all errors, except for notices and coding standards warnings.)
; E_ALL & ~E_NOTICE | E_STRICT (Show all errors, except for notices)
; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
; E_ALL | E_STRICT (Show all errors, warnings and notices including coding standards.)
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting
error_reporting = E_ALL & ~E_NOTICE

…I’ve tried setting everything (and I restart apache each time), but I am unable to get rid of notices.

The only way I’m able to get rid of notice errors is by setting :


display_errors = Off

That is, of course, not something I can do since I need to see errors to fix them, and I would like to see errors on the webpage that I coding rather than log them somewhere.

Can someone help? Is this a bug in PHP 5.3.2 or something I am doing wrong?

Thank you very much for your time!

P. S. Also, how can I get PHP 5.3.2 to support the .php3 extension?

A(Answer):

Hey.

Are you sure you are editing the correct php.ini? I’ve often faced similar situations, to find I am editing the wrong config file.

The "E_ALL & ~E_NOTICE" setting should show all error except notices and standard warnings. If you can’t get this to work via the php.ini file, try adding a line like this to the top of your script. See if it works:

error_reporting(E_ALL & ~E_NOTICE);

This should do the same thing.

Also, how can I get PHP 5.3.2 to support the .php3 extension?

That is not related to the PHP configuration, but rather your HTTP server configuration.

In Apache, to make extensions trigger the PHP module, you would add a line to the httpd.conf file that reads something like:

AddType application/x-httpd-php5 .php .php3 .phtml

This line makes the .php, .php3 and .phtml extensions trigger the PHP module. You can specify whatever extensions you want.

A(Answer):

Thanks very much for the quick response, Atli. I am indeed editing the correct file since:

1. When I set display_errors = Off in the php.ini, all error notifications stop, and
2. phpinfo shows the same path as that of the file that I am editing

Unortunately, adding the line at the top of my script did not work, either…

A(Answer):

I’d file a bug at http://bugs.php.net

A(Answer):

What is the value for "error_reporting" in your phpinfo output?

I’ve been testing this myself, and I can’t seem to get any value working for the error_reporting directive in my php.ini file. Doesn’t matter what I set it to, I always get "no value" and all errors are disabled. – I can, however, use the error_reporting() function to set it to whatever I need.

I’ve been playing with this all morning, and nothing seems to work. Even rebooted a few times, just to be sure.

I’m using PHP 5.3.2 (the Ubuntu 10.04 package) on Apache 2.2.

P.S.
If you go ahead and file a bug, please link it here. I’d like to keep an eye on this (and avoid filing a duplicate myself). Thanks.

A(Answer):

Ignore my last. Problem was with the php.ini file itself. There were some trash chars corrupting it… and it only took like 6 hours to figure out xD

(Note to self: when debugging stuff like this, use a fresh copy of the recommended php.ini!)

A(Answer):

Okay, I figured what was going wrong. I set error_reporting in my code, which was overwriting the php.ini error_reporting.

Now the reason that that same stuff was working until I upgraded to PHP 5.3.2 was this – in my code, I set the error_reporting command:

error_reporting(6143);

I should’ve set it as:

error_reporting(E_ALL ^ E_NOTICE);

I’m guessing the meaning of 6143 is different in PHP 5.3.2 compared to in 4.1 (or whatever my earlier version was).

As for the php3 extension, it was to be set in the /etc/httpd/conf.d/php.conf file:

AddHandler php5-script .php .php3
AddType text/html .php

Thank you, Atli, for your suggestions!

LEAVE A COMMENT