What could be causing a PHP script to display a white page when run on localhost but work fine on a web server?

The issue could be related to error reporting settings in PHP. When running on localhost, error reporting may be set to display errors on the page, causing a white screen if there are syntax errors or other issues. To solve this, you can check the error logs for details on the issue or adjust the error reporting settings in your PHP configuration.

// Adjust error reporting settings to display errors on the page
error_reporting(E_ALL);
ini_set('display_errors', 1);