A blank white screen in PHP usually means your PHP application encountered an error, but the error message is hidden.
Instead of showing an error such as a fatal error or syntax error, the browser simply displays a completely blank page.
This is often called the White Screen of Death (WSOD).
The good news is that the blank screen itself is usually not the real problem. The actual PHP error is hidden behind it.
In this guide, you'll learn how to debug a blank white screen in PHP and find the underlying error.
Why Does PHP Show a Blank White Screen?
A blank PHP page can be caused by:
- PHP fatal errors
- Syntax errors
- Memory exhaustion
- Missing PHP extensions
- Incorrect file permissions
- PHP version incompatibility
- Missing included files
- Infinite loops
- Incorrect server configuration
- Errors hidden by disabled error reporting
The first goal is to make PHP show the actual error.
Step 1: Enable PHP Error Reporting
Add the following at the beginning of your PHP file:
<?php error_reporting(E_ALL); ini_set('display_errors', '1'); ini_set('display_startup_errors', '1');
Then reload the page.
Instead of a blank screen, you may see something like:
Fatal error: Uncaught Error: Call to undefined function...
or:
Parse error: syntax error, unexpected token...
The error message usually points directly to the problem.
Important
Do not leave:
ini_set('display_errors', '1');
enabled on a production website.
Displaying PHP errors publicly can expose sensitive information such as file paths, database details, and application code.
Use error logging on production instead.
Step 2: Check the PHP Error Log
If enabling display_errors doesn't show anything, check your PHP or web server error logs.
Common locations include:
/var/log/php/error.log
or:
/var/log/apache2/error.log
For Nginx with PHP-FPM, check the PHP-FPM log configured for your server.
You can also use:
tail -f /var/log/php/error.log
The exact location depends on your PHP and server configuration.
Step 3: Check for PHP Syntax Errors
A syntax error can prevent the entire PHP file from executing.
Example:
<?php $user = [ 'name' => 'Ali', 'email' => 'ali@example.com'
The array is missing:
];
PHP may display a blank page if errors are hidden.
Check the file from the command line:
php -l filename.php
You should see:
No syntax errors detected
if the file is valid.
Step 4: Look for Fatal Errors
A fatal error can stop PHP execution immediately.
For example:
<?php $user->getName();
If $user is not a valid object, PHP may terminate execution.
Other common fatal errors include:
Call to undefined function Class not found Call to a member function on null Allowed memory size exhausted
Enable error reporting or check your error logs to identify the exact error.
Step 5: Check Included and Required Files
A missing required file can stop your application.
Example:
require 'config.php';
If config.php doesn't exist at the expected path, PHP can stop execution.
Check:
- File path
- Filename spelling
- Directory structure
- Case sensitivity
Linux servers are case-sensitive.
For example:
Config.php
and:
config.php
are different filenames.
Step 6: Add Debugging Output
If you're unsure where execution stops, add temporary debugging statements:
echo 'Step 1'; echo 'Step 2'; echo 'Step 3';
If you see:
Step 1 Step 2
but not:
Step 3
you know the problem occurs between Step 2 and Step 3.
You can also use:
var_dump($variable);
or:
print_r($variable);
Remove debugging output after finding the problem.
Step 7: Check PHP Memory Limit
A memory exhaustion error can result in a blank page when errors aren't displayed.
Check your current limit:
php -i | grep memory_limit
You may see:
memory_limit => 128M
If your script processes large datasets, images, or files, it may exceed this limit.
Check the PHP error log for:
Allowed memory size exhausted
Don't simply increase the memory limit without investigating why the application is consuming excessive memory.
Step 8: Check PHP Version Compatibility
Your application may have been built for a different PHP version.
For example, older PHP code may contain functionality that no longer works correctly after upgrading PHP.
Check your PHP version:
php -v
Then verify that your application's PHP version requirements are satisfied.
For Composer-based projects:
composer check-platform-reqs
This can help identify missing PHP extensions or incompatible platform requirements.
Step 9: Check File Permissions
Incorrect permissions can prevent PHP from reading files or writing required data.
Check permissions:
ls -la
For Laravel applications, make sure the appropriate directories are writable by the web server, especially:
storage/ bootstrap/cache/
Avoid using:
chmod -R 777
as a blanket fix.
Instead, configure ownership and permissions correctly for your server environment.
Step 10: Check Your Web Server
The problem may not be PHP code itself.
Check whether Apache or Nginx is correctly passing PHP requests to PHP-FPM.
For Nginx, verify your PHP-FPM configuration.
For Apache, check the relevant Virtual Host and PHP configuration.
Look at the web server logs when the page returns a blank response.
Debugging a Blank White Screen in Laravel
If your blank page is a Laravel application, start with the Laravel log:
storage/logs/laravel.log
Then temporarily enable debugging in .env:
APP_DEBUG=true
Reload the page and check the exception.
After debugging, change it back:
APP_DEBUG=false
Then clear Laravel's cached configuration:
php artisan optimize:clear
For production, keep:
APP_ENV=production APP_DEBUG=false
and investigate the logs instead of displaying exceptions to visitors.
Check Laravel's Environment Configuration
A blank Laravel page can also happen because of an incorrect .env configuration.
Check important values such as:
APP_KEY= APP_ENV= APP_DEBUG= DB_CONNECTION= DB_HOST= DB_DATABASE= DB_USERNAME= DB_PASSWORD=
If APP_KEY is missing, generate it when appropriate:
php artisan key:generate
Then clear cached configuration:
php artisan optimize:clear
Check Composer Dependencies
If the blank screen started after deployment, your production dependencies may be incomplete.
Run:
composer install --no-dev --optimize-autoloader
Then:
php artisan optimize:clear
Check the error log again if the application still doesn't load.
A Quick Debugging Process
When you encounter a blank white PHP page, follow this order:
1. Enable errors temporarily
error_reporting(E_ALL); ini_set('display_errors', '1');
2. Reload the page
Look for the actual PHP error.
3. Check PHP and server logs
Look for fatal errors, parse errors, memory errors, and permission problems.
4. Check syntax
php -l filename.php
5. Check recent code changes
If the application worked before a recent change, start debugging there.
6. Check PHP version and extensions
php -v php -m
7. If it's Laravel, check
storage/logs/laravel.log
and temporarily use:
APP_DEBUG=true
8. Disable debug mode after fixing the problem
APP_DEBUG=false
Don't Hide the Problem With @
You may see code like:
@$result = someFunction();
The @ operator suppresses errors.
Avoid using it as a solution to a blank page.
Suppressing the error doesn't fix the underlying problem and can make debugging significantly harder.
Find out why the error is happening instead.
Final Checklist
If your PHP website shows a completely blank white screen:
- ✓ Enable PHP error reporting temporarily
- ✓ Check PHP error logs
- ✓ Check Apache/Nginx logs
- ✓ Run php -l to find syntax errors
- ✓ Look for fatal errors
- ✓ Check included files
- ✓ Check PHP memory usage
- ✓ Verify PHP version compatibility
- ✓ Check file permissions
- ✓ If using Laravel, check storage/logs/laravel.log
- ✓ Check .env configuration
- ✓ Clear Laravel cache
- ✓ Disable public error display after debugging
A blank white screen is usually a symptom, not the actual error. The fastest way to solve it is to reveal or locate the hidden PHP error first, then fix the underlying problem.
If your PHP or Laravel website is still showing a blank white screen, send me the error log or a screenshot of what you're seeing. I can help identify the root cause.