Error handling is an important part of any developer as it provides vital flaws about the program developed by the developer. So, it becomes very crucial to learn the techniques to manage it.
As a developer, we have been told that you should not show errors on the production server because of the security risk due to the path displayed by the PHP errors displayed on the screen. So, we add the following code for the production server,
ini_set('error_reporting', 0); error_reporting(0); ini_set('display_errors', FALSE);
But, without error logs, developers cannot able to know actual problems or flaws in the system. So, rather than hiding errors, developers should store them in the log files. We can achieve this using the following code,
ini_set('error_reporting', E_ALL); error_reporting(E_ALL); ini_set('log_errors', TRUE); ini_set('html_errors', FALSE); ini_set('error_log', LOG_PATH.'error.log'); ini_set('display_errors', FALSE);
This way, we can manage error logs and hide errors on the production server. We can manage separate log files for the different modules of the project.