# Hide PHP Errors From Visitors

> Turns off on-screen PHP warnings and errors for everyone except logged-in administrators, so file paths are never shown to the public.

- Type: PHP
- Runs: Run everywhere
- Category: [Security](https://wpide.com/library/category/security/)
- Tags: security, errors, debug
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/hide-php-errors-from-visitors/

## Code

```php
if ( ! ( is_user_logged_in() && current_user_can( 'manage_options' ) ) ) {
    ini_set( 'display_errors', '0' );
}
```

## Notes

Errors are still written to the error log if logging is enabled.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Hide PHP Errors From Visitors" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
