Is it possible to prevent PHP errors from being visible to regular users while still logging them for administrators?

To prevent PHP errors from being visible to regular users but still log them for administrators, you can use the error_reporting function to set the error reporting level to not display errors on the webpage, and then use the error_log function to log the errors to a file that only administrators can access.

// Set error reporting level to not display errors on webpage
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);

// Log errors to a file
ini_set('log_errors', 1);
ini_set('error_log', '/path/to/error.log');