XAMPP shows a blank page instead of PHP errors
Blank white pageShort 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.
Fix it fast
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');2Match what you see, then jump to its fix
- 1
The page above shows display_errors is off, or the value 0display_errors is Off in the php.ini that Apache loadsFix - 2
You edited php.ini but the first-step page shows the old settingsphp.ini was changed but Apache still runs the old valueFix - 3
Display 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
- 1
What does the error look like?
Blank white pageNo 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 = On3Verify
Restart Apache from the XAMPP control panel and reload the broken page.
<?php
echo $undefined_variable;Confirmed by php.net
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 panel3Verify
Reload the first-step page; display_errors now shows 1 or On.
# reload the page from the first stepConfirmed by php.net
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.php2Fix
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.phpConfirmed by php.net
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
Servers
display_errors has no effect on PHP behind nginx and PHP-FPM
500 Internal Server Error with no PHP message in the browser
With nginx there is no web-server PHP setting.
4 causes, each with a fixBack end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack 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 fixBack end
Apache returns 500 with Premature end of script headers
500 Internal Server Error
Apache ran your script, but the script printed no valid HTTP header before its output.
3 causes, each with a fixBack end
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fixBack end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fix