Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

XAMPP shows a blank page instead of PHP errors

ErrorBlank white page

Short answer

A blank page means PHP hit an error and was told not to print it. In XAMPP, find the php.ini that Apache loads, set error_reporting to E_ALL and display_errors to On there, then restart Apache. A syntax error in the same file cannot be switched on by ini_set() in that file, so use php.ini or an include.

  • Applies to XAMPP 8.2, PHP 8.2, Windows 11
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask the same PHP that Apache uses which php.ini it loaded. Create a small page and open it in the browser; a CLI command can show a different file.

    <?php
    echo php_ini_loaded_file(), "<br>";
    echo ini_get('display_errors') === '' ? 'display_errors is off' : 'display_errors = ' . ini_get('display_errors');
  2. 2Match what you see, then jump to its fix

    1. 1The page above shows display_errors is off, or the value 0display_errors is Off in the php.ini that Apache loadsFix
    2. 2You edited php.ini but the first-step page shows the old settingsphp.ini was changed but Apache still runs the old valueFix
    3. 3Display is On in php.ini, or ini_set('display_errors', 1) is at the top of the broken file, and the page is still blankThe error is a syntax error in the same file that sets ini_set()Fix

What does the error look like?

  • Blank white page
  • No Warning or Notice text, although the code clearly has a mistake

Cause 1 of 3

display_errors is Off in the php.ini that Apache loads

1Check

The bundled php.ini-production sets display_errors to Off and php.ini-development sets it On. The manual warns display_errors should never be on in production.

<?php
var_dump(ini_get('display_errors'), ini_get('error_reporting'));

2Fix

Edit the file the first step printed. For a local development machine use the development values, then save it.

; php.ini
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
log_errors = On

3Verify

Restart Apache from the XAMPP control panel and reload the broken page.

<?php
echo $undefined_variable;

Confirmed by php.net

Did this fix it?

Cause 2 of 3

php.ini was changed but Apache still runs the old value

1Check

With a server module, PHP reads php.ini once at startup. Also, the file you edited may not be the one PHP loaded.

<?php
echo php_ini_loaded_file(), '<br>', php_ini_scanned_files();

2Fix

Edit the file named by php_ini_loaded_file() in the browser, then restart Apache. Later .ini files in the scan directory can override it, so look at those too.

# edit the file printed by php_ini_loaded_file()
# then stop and start Apache in the XAMPP control panel

3Verify

Reload the first-step page; display_errors now shows 1 or On.

# reload the page from the first step

Confirmed by php.net

Did this fix it?

Cause 3 of 3

The error is a syntax error in the same file that sets ini_set()

1Check

PHP parses the whole file before running any line of it, so an ini_set() call at the top of a file with a parse error never runs.

php -l index.php

2Fix

Turn the setting on in php.ini, or move ini_set() and error_reporting() into a small bootstrap file and include the file that has the error.

<?php
// debug.php
error_reporting(E_ALL);
ini_set('display_errors', '1');
include 'index.php';

3Verify

Open debug.php in the browser; the parse error now prints.

php -l index.php

Confirmed by php.net

Did this fix it?

How do I stop it coming back?

  • Keep display_errors On only on development machines; in production keep it Off and log errors with log_errors and error_log.
  • Use error_reporting = E_ALL so notices and deprecations show before an upgrade.
  • Run php -l on a file after editing it, to catch parse errors without a browser.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

Apache returns 403 when a URL contains %3F

a request like /page%3Fname=test is refused while /page?name=test works

Recent Apache httpd blocks a rewrite when the request contains an encoded question mark (%3F) and the rewritten target has a literal ?.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.