Archive

Archive for December, 2016

[php] turn off deprecated errors

December 6, 2016 Leave a comment

Problem
I have a PHP application running on a webserver and the system administrator sent me an email one day that the Apache log is full of PHP deprecated warning messages and it is caused by my page.

The warning message was the following:

PHP Deprecated:  preg_replace(): The /e modifier 
is deprecated, use preg_replace_callback instead 

Solution
Investigating the code, I had “preg_replace()” all over the source. No way that I would correct them manually everywhere. I chose a quick and dirty solution and added the following line to the top of the entry PHP file:

error_reporting(0); // Turn off warning, deprecated, 
                    // notice everything except error

Done, no more barking. This tip is from here.

When the application stops running and terminates with an error, I’ll update the application.

Advertisements
Categories: php