How can error reporting be configured in PHP to help identify and troubleshoot issues in code?
Error reporting in PHP can be configured using the error_reporting function to specify which types of errors should be reported. By setting the error_reporting level to E_ALL, all errors, warnings, and notices will be displayed, helping to identify and troubleshoot issues in the code. Additionally, displaying errors on the screen can be enabled by setting the display_errors directive to On in the php.ini file.
// Enable error reporting for all errors, warnings, and notices
error_reporting(E_ALL);
// Display errors on the screen
ini_set('display_errors', 1);