How can error reporting be enabled in PHP to help troubleshoot and debug issues in code?

To enable error reporting in PHP, you can set the error_reporting level to E_ALL in your PHP script or in the php.ini configuration file. This will display all errors, warnings, and notices, helping you to identify and fix issues in your code more easily.

// Enable error reporting
error_reporting(E_ALL);