Are you seeing a completely blank page in your PHP website? No error message, no warning — just a white screen? This issue is commonly known as the White Screen of Death. In this guide, you will learn how to fix blank page error in PHP step by step.
What Causes Blank Page Error in PHP?
- Fatal error in code
- Syntax error
- Memory limit exceeded
- Missing include file
- Server configuration issue
Step 1: Enable Error Reporting
Most of the time, errors are hidden. Add this code at the top of your PHP file:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>
Reload the page. Now the actual error message should appear.
Step 2: Check Server Error Logs
If errors still do not show, check your server error log. You can find it in:
- cPanel → Error Logs
- Hosting control panel
- Apache error.log file
Step 3: Check for Missing Semicolons or Brackets
A small syntax mistake can break the entire page. Example:
echo "Hello World"
Correction:
echo "Hello World";
Step 4: Verify Included Files
Sometimes a missing file causes a fatal error.
include("config.php");
Make sure the file exists in the correct directory.
Step 5: Increase Memory Limit
If your script consumes too much memory, increase memory limit:
ini_set('memory_limit', '256M');
Step 6: Check Database Connection
$conn = mysqli_connect("localhost","root","","database");
if(!$conn){
die("Database connection failed");
}
Best Practices to Avoid Blank Page Errors
- Develop on local server first
- Use version control (Git)
- Log errors instead of displaying them in production
- Test code after every update
Conclusion
Blank page error in PHP is usually caused by hidden fatal errors. By enabling error reporting, checking logs, and reviewing syntax carefully, you can quickly identify and fix the issue.
Follow this step-by-step process and your PHP application will run smoothly again.
Frequently Asked Questions
Add the following code at the top of your PHP file:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>
error.log file on your server.
