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');
Related Questions
- What potential issues can arise when establishing an RCon connection using the BattlEye Protocol in PHP?
- What are the potential pitfalls of storing values from a MySQL database column in variables using PHP?
- What are the potential risks of using outdated mysql_* functions in PHP and what are the recommended alternatives?