PHP Site Shows a Blank Page or 500 Error: How to See the Real Error
A PHP page is blank or gives error 500. Turn on error logging safely, read the message and fix the line it names.
A blank page or a 500 error from a PHP file usually hides a PHP error, because servers hide errors from visitors for safety. You need to read them yourself.
Step 1: Check the error log
Your hosting panel has an Error log page. It names the file, the line and the problem. Look at the newest lines.
Step 2: Show errors while testing
At the very top of the failing PHP file, add:
ini_set( 'display_errors', '1' );
error_reporting( E_ALL );
Reload the page. A syntax error in the same file may stop these lines from running, so use the log or your host's PHP settings in that case.
Step 3: Read the message
- Parse error / syntax error: a missing semicolon, bracket or quote near the named line.
- Call to undefined function: a missing PHP extension, or a function that is gone in your PHP version. See our PHP version guide.
- Failed to open stream / No such file: the path in
includeorrequireis wrong. - Allowed memory size exhausted: see our memory guide.
Step 4: Check .htaccess
A wrong line in .htaccess causes a 500 error. Rename it temporarily to test.
Step 5: Turn display off again
Remove the display_errors line when finished. Showing errors to visitors can leak file paths and other private details.
Related guides
- WordPress White Screen of Death: How to Fix a Blank Page
- WordPress Theme Broke the Site: Switch Back to a Default Theme Without Dashboard Access
- WordPress Posts or Pages Show 404 Not Found but the Homepage Works
- WordPress Pages Show 404 Not Found (Posts Work, Pages Do Not)