What are some alternative methods for notifying administrators about database connection issues instead of sending emails directly from PHP scripts?

One alternative method for notifying administrators about database connection issues is to log the errors to a file instead of sending emails directly from PHP scripts. This can be done by using PHP's error_log function to write the error messages to a specified file location.

// Set the file path for the error log
$logFile = '/path/to/error.log';

// Log database connection errors to the specified file
if (!$connection) {
    error_log('Database connection error: ' . mysqli_connect_error(), 3, $logFile);
}