phperror-reporting

PHP error_reporting either on or off


I'm having trouble turning off deprecated warnings for a short period of time. They're coming from a junk-pile script that I'm forced to work on for a while, wherein they use preg_replace with the /e modifier excessively. Rather than go and fix all the places that do this, it seemed like a better idea to turn off deprecated warnings while I'm working on it.

The problem, oddly enough, is that the error_reporting function at the beginning said script seems to have only an "On/Off" effect. That is, I can turn reporting fully off with error_reporting(0), and I can have it all on with something like error_reporting(E_ALL). But using any of the following options has no affect. I still get some 100+ deprecated warnings at the top of my page.

<?php
error_reporting(E_ALL ^ E_DEPRECATED);
error_reporting(E_ALL & ~E_DEPRECATED);
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);

I've verified that my php.ini file is set to E_ALL & ~E_DEPRECATED) (24575), and it shows as such in phpinfo(). The .htaccess file in the project root is empty. Why there even is one, I don't know.

PHP 5.5.9-1ubuntu4.4

Any ideas?


Solution

  • I would say there is probably another page or script that is being included that is setting error_reporting to a different value. You can call error_reporting() with no args to get the current value. Set it to something and check that the value hasn't changed after including other files.