What is the best practice for handling error reporting in PHP on production systems?

When handling error reporting in PHP on production systems, it is best practice to log errors to a file instead of displaying them to the user. This helps to maintain security by not revealing sensitive information to potential attackers. Additionally, logging errors allows for easier troubleshooting and debugging of issues that may arise.

// Set error reporting level
error_reporting(E_ALL);

// Set error log file
ini_set('error_log', '/path/to/error.log');

// Log errors to file
ini_set('log_errors', 'On');