Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force error_reporting mode in PHP 5.3

I have some code that's encrypted with ioncube and it's also written for < PHP 5.3. There's a ton of deprecated code, which would still work, but there's error messages all over the site.

Is there a way of externally forcing error_reporting to E_ALL ^ E_DEPRECATED or similar? I'm sure in the code they're hardcoding to E_ALL for some reason.

like image 302
Noodles Avatar asked Oct 05 '10 03:10

Noodles


People also ask

What is the use of Error_reporting () function in PHP?

The error_reporting() function specifies which errors are reported. PHP has many levels of errors, and using this function sets that level for the current script.

How do I enable display errors in PHP?

The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);

How do I turn off PHP error reporting?

To turn off or disable error reporting in PHP, set the value to zero. For example, use the code snippet: <? php error_reporting(0); ?>


1 Answers

Disable display_errors and log them to a file instead. That is standard procedure for any production web site.

In an Apache config file, php_admin_value error_reporting X should make it impossible to be overridden by user code, where X is the integer value you want.

Also, set_error_handler() might be of use if you want to do some runtime checks.

like image 159
Matthew Avatar answered Oct 21 '22 00:10

Matthew