How7oHow7o
  • Home
  • Tools
    • All Tools
    • Image Tools
    • Text & String Tools
    • Video Tools
    • Developer Tools
    • PDF Tools
    • Calculators & More
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Display PHP Errors
Share
Notification Show More
Font ResizerAa
How7oHow7o
Font ResizerAa
  • Tools
  • Prank Screens
  • Learn
  • Blog
Search
  • Home
  • Tools
    • All Tools
    • Image Tools
    • Text & String Tools
    • Video Tools
    • Developer Tools
    • PDF Tools
    • Calculators & More
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > Web Development > How to Display PHP Errors
Web Development

How to Display PHP Errors

how7o
By how7o
Last updated: May 10, 2026
7 Min Read
Display PHP errors — ini_set + php.ini configuration
SHARE

To display PHP errors on a page that’s returning HTTP 500 or a blank screen, add three ini_set calls at the top of your script — display_errors, display_startup_errors, and error_reporting(E_ALL). For parse errors that happen before any code runs, editing php.ini, .htaccess, or .user.ini is the only path. This guide covers all four and why you should never leave any of them on in production.

Contents
  • TL;DR
  • In-script toggle — ini_set
  • Parse errors — edit php.ini
  • Shared hosting — .user.ini
  • Apache mod_php — .htaccess
  • Production: log, don’t display
  • Laravel / WordPress specifics
  • Frequently asked questions
  • Related guides
  • References

Last verified: 2026-04-23 on PHP 8.3. Originally published 2022-06-16, rewritten and updated 2026-04-23.

TL;DR

// Top of your PHP file (runtime errors)
ini_set('display_errors',         '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
# php.ini (for parse errors and permanent settings)
display_errors         = On
display_startup_errors = On
error_reporting        = E_ALL

# .htaccess (Apache + mod_php)
php_flag display_errors 1
php_value error_reporting 32767

In-script toggle — ini_set

<?php
ini_set('display_errors',         '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

The three lines together:

  • display_errors — show runtime errors (notices, warnings, fatals) in the response.
  • display_startup_errors — show errors that happen during PHP’s own startup phase (extension loading, failed config parsing). Off by default even with display_errors = On, which is why sites with broken extensions sometimes show blank pages.
  • error_reporting(E_ALL) — include every error level in the “report this” set. Without it, display_errors only shows whatever level the current config allows.

This covers runtime errors from any point after the three lines have executed. It does not catch parse/syntax errors in the same file — PHP parses the entire file before running the first line.

Parse errors — edit php.ini

# Find which php.ini is actually loaded
php --ini

# Edit the loaded file
sudo nano /etc/php/8.3/fpm/php.ini

# Flip these three
display_errors         = On
display_startup_errors = On
error_reporting        = E_ALL

# Restart PHP so the change takes effect
sudo systemctl restart php8.3-fpm

Editing php.ini requires SSH + sudo. Changes take effect after the next PHP-FPM (or Apache with mod_php) restart. This is the authoritative place for error settings — ini_set can override most of them at runtime, but only after parsing.

display php errors — ini_set at top of script, php.ini for parse errors, .user.ini for shared hosts

Shared hosting — .user.ini

# .user.ini — place in your site's document root
display_errors         = On
display_startup_errors = On
error_reporting        = E_ALL

PHP reads .user.ini files in the document root hierarchy — no web server config required. Works on CGI/FastCGI setups (most modern shared hosts). Changes don’t take effect immediately: PHP caches the file for user_ini.cache_ttl seconds (default 300). For faster iteration, either wait 5 minutes or ask the host to flush the cache.

Apache mod_php — .htaccess

# .htaccess — Apache with mod_php only
php_flag display_errors 1
php_flag display_startup_errors 1
php_value error_reporting 32767

Works only on Apache with mod_php (increasingly rare — most modern hosts run PHP-FPM). If your host uses nginx, LiteSpeed, or PHP-FPM under Apache, .htaccess php_* directives are ignored — use .user.ini instead.

Production: log, don’t display

# Production php.ini
display_errors         = Off
display_startup_errors = Off
log_errors             = On
error_log              = /var/log/php/error.log
error_reporting        = E_ALL

Never leave error display on in production. Errors include file paths, stack traces, database names, and sometimes query parameters — all of which help an attacker map your system. Log errors to a file instead, and review them via tail -f /var/log/php/error.log or an aggregator like Sentry, Rollbar, or Papertrail.

Laravel / WordPress specifics

  • Laravel — APP_DEBUG=true in .env turns on Laravel’s Whoops error page. Keep it false in production.
  • WordPress — define('WP_DEBUG', true); in wp-config.php enables WP’s debug mode. Pair with define('WP_DEBUG_LOG', true); to log to wp-content/debug.log.

Framework-level debug toggles are more convenient than raw PHP ini_set calls for app-level development. Use them for app-specific issues; reach for the PHP-level settings when even the framework isn’t booting.

Frequently asked questions

What’s the quickest display php errors toggle?

Three lines at the top of your PHP file: ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL);. This turns on error display for the current script. Works without editing any config files, but doesn’t catch parse errors — those happen before the script runs. For parse errors, edit php.ini or .htaccess.

Is this safe for production?

No. Displaying errors to the browser leaks file paths, database schemas, and sometimes credentials — gold for attackers. Production should have display_errors = Off and log_errors = On so errors go to a log file instead. Reserve the “display errors” toggle for development environments and for diagnosing a specific broken script locally.

Why do parse errors not show even with ini_set?

PHP parses the whole file before running any code. A syntax error is caught at parse time — before ini_set has had a chance to execute. To display parse errors you have to turn display_errors on at a scope that applies before parsing: php.ini, .htaccess, or .user.ini for per-directory overrides. Once display_errors is on via config, the ini_set calls become optional.

What’s the difference between display_errors and display_startup_errors?

display_errors controls errors during script execution. display_startup_errors controls errors during PHP’s own startup — extension loading, ini-file parsing, server initialization. You usually want both on in development; both off in production. Leaving startup errors on catches broken extension configs that otherwise produce only blank pages.

How do I see errors if I can’t edit php.ini?

Two options: .user.ini files (per-directory overrides, work on most shared hosts that use CGI/FPM), or .htaccess with php_flag display_errors 1 (requires Apache with mod_php). The .user.ini approach is more portable — it works on any modern PHP regardless of web server. Changes take effect after user_ini.cache_ttl seconds (default 300).

Related guides

  • How to Install PHP 8.x on Ubuntu 22.04 — a fresh PHP install to locate php.ini in.
  • How to Fix cURL Error 60 SSL Certificate Problem in Laravel — another php.ini edit.
  • How to Run a Laravel Project Without a .env File — config-cache debugging.
  • How to Troubleshoot MariaDB Not Starting — log-based debugging for another service.

References

PHP error-handling runtime configuration: php.net/manual/en/errorfunc.configuration. .user.ini: php.net/manual/en/configuration.file.per-user.

TAGGED:configurationphptroubleshooting

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article PHP convert string to uppercase — strtoupper and mb_strtoupper How to Convert a String to Uppercase in PHP
Next Article aaPanel MySQL root password reset via the Databases page How to Reset the MySQL Root Password in aaPanel
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

You Might Also Like

Change SSH port on Linux — firewall, SELinux, sshd_config, systemctl restart
Server Management

How to Change the Default SSH Port on Linux

7 Min Read
Fix broken cPanel disk quotas with the fixquotas script
Server Management

How to Fix Quotas in cPanel

5 Min Read
SSH key authentication — keypair, terminal window, lockout-protection parallel session
Server Management

How to Set Up SSH Key Authentication on Ubuntu (Without Locking Yourself Out)

14 Min Read
Laravel run without .env file — env() fallback in config/app.php
Web Development

How to Run a Laravel Project Without a .env File

8 Min Read
How7oHow7o

Free browser-based tools, prank screens, and step-by-step tech tutorials. No signup, nothing uploaded.

  • Private by design — your files never leave your device
  • Instant — no signup, no install, no waiting
  • Always free — no trials, no watermarks, no paywalls

Tools

  • PDF Editor
  • Image Upscaler
  • JPEG Compressor
  • Password Generator
  • QR Code Generator
  • Video Trimmer
  • See all tools →

Pranks

  • Cracked Screen Prank
  • Fake Blue Screen (BSOD)
  • Fake Console Update Screen
  • Fake Disk Format
  • Fake Low Battery
  • Fake Virus Scan
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?