PHP shows a blank page and no error message
A white page with no output at all (HTTP 500 in the access log)Short answer
A blank page means PHP hit an error but was told not to print it. Check display_errors and error_reporting in the php.ini the web server really uses, not the CLI one. Turn display on in development only. On production, set log_errors and read the log instead of showing errors.
Fix it fast
1Find out which cause you have
Ask PHP which settings are active and which php.ini was loaded. Run it for the CLI, then compare with phpinfo() served through the web server, because the two often use different files.
php --ini php -i | grep -E "^(display_errors|error_reporting|log_errors|error_log) "2Match what you see, then jump to its fix
- 1
Blank page; phpinfo() through the web server shows display_errors => Offdisplay_errors is Off in the php.ini that serves the siteFix - 2
ini_set('display_errors', 1) at the top of the script, still a blank page, and the problem is a syntax errorThe error is a parse error in the same file as ini_set()Fix - 3
display_errors is Off, log_errors is Off or error_log points at a file PHP cannot writeProduction: errors are hidden on purpose and nobody reads the logFix - 4
A working page prints Warning: lines above the HTMLYou want a warning to stop appearing on the pageFix
- 1
What does the error look like?
A white page with no output at all (HTTP 500 in the access log)No Warning or Fatal error text, even though the script is brokenini_set('display_errors', 1) has no effect on a Parse error in the same file
Cause 1 of 4
display_errors is Off in the php.ini that serves the site
1Check
The shipped php.ini-production file sets display_errors to Off, and php.ini-development sets it to On. A server installed from the production template hides every error.
php --ini
# Debian/Ubuntu package path; use the "Loaded Configuration File" from phpinfo() on other systems
grep -n -E "^(display_errors|error_reporting)" /etc/php/8.3/fpm/php.ini2Fix
In development, set both directives in the php.ini used by the web server (the path comes from the web SAPI, not from the CLI), then restart PHP-FPM or Apache.
; php.ini (development machine only)
display_errors = On
error_reporting = E_ALL3Verify
Reload a page that has a deliberate error and the message appears. Remove the test error afterwards.
sudo systemctl restart php8.3-fpmConfirmed by php.net
Cause 2 of 4
The error is a parse error in the same file as ini_set()
1Check
PHP parses the whole file before it runs any line of it. A ini_set() call inside a file that fails to parse never executes, so it cannot turn display on for that file's own parse error.
php -l public/index.php2Fix
Set the directives in php.ini, or put the ini_set() calls in a small bootstrap file and include the broken file from it.
<?php
// bootstrap.php
error_reporting(E_ALL);
ini_set('display_errors', '1');
include __DIR__ . '/public/index.php';3Verify
Open bootstrap.php in the browser; the parse error from index.php is now printed.
php -l public/index.phpConfirmed by php.net
Cause 3 of 4
Production: errors are hidden on purpose and nobody reads the log
1Check
Showing errors to visitors is not advised on a live site. The manual's advice is to log them instead. log_errors defaults to off, so you must switch it on.
php -i | grep -E '^(log_errors|error_log) '2Fix
Keep display off, turn logging on and give error_log a path the PHP user can write to.
; php.ini (production)
display_errors = Off
log_errors = On
error_log = /var/log/php/error.log3Verify
Trigger one error, then read the last lines of the log.
sudo tail -n 20 /var/log/php/error.logConfirmed by php.net
Cause 4 of 4
You want a warning to stop appearing on the page
1Check
Find the line named in the message. The @ operator only silences diagnostics (warnings, notices); it also hides errors you did not expect, so it should be a last resort.
grep -rn "Warning" storage/logs/ | tail -n 52Fix
Fix the cause first, for example test the value with isset() before reading it. If a warning is expected and harmless, silence only that one expression, and keep display_errors Off on production.
<?php
$port = isset($config['port']) ? $config['port'] : 3306;3Verify
Reload the page; the warning is gone and the log stays quiet.
php -l config.phpConfirmed by php.net
How do I stop it coming back?
- Use php.ini-development locally and php.ini-production on servers, and keep both in version control notes.
- On production, log errors to a file and rotate it, so a blank page always has a log line behind it.
- Run php -l on changed files in CI so parse errors never reach the server.
- Compare php --ini with phpinfo() from the web server whenever a setting seems ignored.
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
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 fixBack end
AWS SDK for PHP rejects requests: the signature is from the future
Signature not yet current: {date} is still later than {date}
AWS compares the timestamp in your signed request with its own clock.
2 causes, each with a fix