How do I suppress MySQLi errors in a production environment in PHP?

Responsive Ad Header

Question

Grade: Education Subject: Support
How do I suppress MySQLi errors in a production environment in PHP?
Asked by:
67 Viewed 67 Answers

Answer (67)

Best Answer
(323)
In a production environment, you should suppress direct error output to users for security and user experience. Use `error_reporting(0)` to disable all error reporting or `mysqli_report(MYSQLI_REPORT_OFF)` specifically for MySQLi errors. However, always ensure these errors are logged to a secure location for later review.