Question

I want to manage error message display control,

and I Googled for a while,

and I found that there are several ways to do it.

which method do I have to choose?

The thing I want to do is that

I don't want to PHP
shows up any errors on users display,

on Production Server.

Was it helpful?

Solution

Use error_reporting()

On production, disable errors by doing:

error_reporting(0);

Report runtime errors on development like this:

error_reporting(E_ERROR | E_WARNING | E_PARSE);

And report all errors like this:

error_reporting(E_ALL);

See the above link for a complete list of report_level constants with detailed descriptions, as well as the manual page:

http://us.php.net/manual/en/function.error-reporting.php

OTHER TIPS

It's best to log all errors to a file:

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 0);
ini_set('log_errors', 1);
ini_set('error_log', '/tmp/php_errors.log');

On unix, you can watch errors using this command:

bash$ tail -f /tmp/php_errors.log

Or you can just open the log file in a text editor.

This setup can be used on a production server as well, you can download the php_errors.log file periodically to see if there are any bugs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top