How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Display PHP Errors
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • 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.

FacebookLike
XFollow
PinterestPin
InstagramFollow
Most Popular
Laravel Eloquent ORM — a model class mapping to a database table with query methods
Laravel Eloquent ORM: The Complete Guide to Querying Your Database
June 16, 2026
Set vi as the default editor in Ubuntu — a terminal opening the vim editor
How to Set vi (Vim) as the Default Editor in Ubuntu
June 8, 2026
rsync says ALL DONE but files are missing — a terminal showing ALL DONE next to an empty folder
rsync Says “ALL DONE” but Files Are Missing: How to Verify
June 8, 2026
Migrate a website to a new server with rsync — files copying from an old server to a new one over SSH
How to Migrate a Website to a New Server With rsync
June 8, 2026
Bun runtime — faster JS toolkit replacing npm in Laravel projects
How to Install Bun Runtime on Ubuntu (And Use It in a Laravel Project)
May 24, 2026

You Might Also Like

Login to Laravel programmatically without a password (Auth::login and loginUsingId)
Web Development

Login to Laravel Programmatically Without a Password (Auth::login & loginUsingId)

4 Min Read
Reload DataTables with a new Ajax URL
Web Development

How to Reload DataTables with a New Ajax URL

4 Min Read
WooCommerce product view counter — meta-based counter with increment and display hooks
Web Development

How to Display a Product View Counter in WooCommerce Without a Plugin

7 Min Read
PHP convert string to uppercase — strtoupper and mb_strtoupper
Web Development

How to Convert a String to Uppercase in PHP

6 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • 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?