Skip to main content

How to Display PHP Errors Temporarily During Development

You can enable the display of PHP errors to identify issues during the development of a website. This process allows you to see specific error messages and warnings directly in your browser instead of seeing a blank page or a generic server error.

You can enable the display of PHP errors to identify issues during the development of a website. This process allows you to see specific error messages and warnings directly in your browser instead of seeing a blank page or a generic server error.

Important: Only enable error display during the development phase. You should disable error reporting on a live production website to prevent sensitive system information from being exposed to the public.

Before you begin

You will need:

  • Access to your website's file system via an FTP client or a File Manager.

  • A local copy of the site or a development environment where it is safe to display errors.

Displaying PHP errors via .user.ini or php.ini

Depending on your server configuration, you can enable error reporting by modifying a .user.ini or php.ini file in your website's root directory. This is not available on Shared Windows packages.

  1. Connect to your server using an FTP client or your hosting control panel's File Manager.

  2. Navigate to the root directory of your website (typically public_html or a folder named after your domain).

  3. Locate the .user.ini file. If it does not exist, you may need to create it.

  4. Open the file and add or modify the following lines:

    display_errors = On
    display_startup_errors = On

  5. Save the file and refresh your website to see if errors appear.

Displaying PHP errors via a script

If you cannot modify the global configuration files, you can enable error reporting for a specific script or page by adding PHP code directly to your file.

  1. Open the specific PHP file where you are experiencing issues (e.g., index.php or a plugin configuration file).

  2. Add the following code block at the top of the file, immediately after the opening <?php tag:

    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);

  3. Save the file and refresh the page.

Confirm the result

  • When a PHP error occurs, the specific error message, file path, and line number will appear directly on the webpage.

  • The page will no longer appear as a blank white screen when a script fails.

How to stop displaying PHP errors on a production website

Once you have finished your development and moved your site to a live environment, you must disable error reporting to maintain security.

  1. Access your .user.ini or php.ini file via FTP or File Manager.

  2. Change the values to:

    display_errors = Off
    display_startup_errors = Off

  3. Save the file.

Limitations

  • These changes only affect the display of errors in the browser. They do not stop the errors from being recorded in the server's internal error logs.

  • If your server's global configuration overrides your local .user.ini file, you may need to contact Hostek support to verify the correct file to edit.

Did this answer your question?