Skip to content
PHP Logo

How can one prevent errors from being displayed in PHP?

To prevent errors from being displayed in PHP, you can set the error_reporting level to not display errors on the screen by using the error_reporting function and setting it to 0. Additionally, you can log errors to a file by setting the error_log directive in the php.ini file.

php
// Set error reporting level to not display errors on the screen
error_reporting(0);