Tools
Log in
English

Learn to codeSecurity check

PHP errors shown on screen

MediumP06PHP servers (Linux and Windows)

Turn off display_errors so visitors never see error text, and keep errors in a…

What is the risk

With display_errors on, errors print file paths, SQL and parts of your settings on the page. Attackers trigger errors on purpose to learn how the server is built.

Hiding errors does not stop bugs such as PHP2SHELL. Hiding and fixing are separate jobs.

How to check

Linux

php -i | grep -E '^(display_errors|log_errors)'
grep -rn '^display_errors' /etc/php/*/fpm/php.ini /etc/php.ini 2>/dev/null

Windows PowerShell (admin)

& "C:\php\php.exe" -i | Select-String display_errors

How to fix

php.ini

display_errors = Off
display_startup_errors = Off
log_errors = On

Edit php.ini and restart PHP. Read errors in the web server error log or the file set by error_log.

Debian / Ubuntu

sudo systemctl restart php8.3-fpm

RHEL / Rocky / Alma

sudo systemctl restart php-fpm

Windows PowerShell (admin)

if (Get-Service W3SVC -ErrorAction SilentlyContinue) { iisreset } else { Get-Service *apache* -ErrorAction SilentlyContinue | Restart-Service }

Restarts IIS if installed, otherwise the Apache service. With XAMPP press Stop then Start for Apache in the Control Panel.

How to prevent it

  • Keep production and development settings apart.
  • Search your code for ini_set calls that turn display_errors back on.

Check again after fixing

Linux

grep -rn '^display_errors' /etc/php/*/fpm/php.ini /etc/php.ini 2>/dev/null

It should say Off.

Run the downloaded check again and make sure this item passes.

Security check home