PHP whitespace: Headers already sent

In this example, you will download the attached zip file and activate it.

Download Zip

Expected Outcome

Once activated, you should see the following error on your screen:

Screen Shot showing error message

This time you may not see any other errors!

Top ↑

How to fix

If you haven’t already, turn on debug by editing your wp-config.php file and changing the WP_DEBUG define to true: define('WP_DEBUG', true);

Now you should have an error like the following at the bottom of your Admin Dashboard:

Notice: ob_end_flush(): failed to send buffer of zlib output compression (0) in /Applications/MAMP/htdocs/wordpress/wp-includes/functions.php on line 2732

or this at the top:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/wordpress/wp-content/plugins/twitter-profile-field/twitter-profile-field.php:28) in /Applications/MAMP/htdocs/wordpress/wp-includes/option.php on line 571

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/wordpress/wp-content/plugins/twitter-profile-field/twitter-profile-field.php:28) in /Applications/MAMP/htdocs/wordpress/wp-includes/option.php on line 572

The actual line numbers may vary based on your install. The important information is the part that mentions the pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the Plugin Directory or can be cost-based plugin from a third-party: plugins/twitter-profile-field/twitter-profile-field.php:28

If you open that file in a code editor on your computer, you’ll see there are extra lines after the closing PHPPHP PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. tag:

Screen Shot showing added extra lines

Once you remove these extra lines, the error will go away. In this case, it’s easiest to remove the trailing PHP tag:

Screen Shot showing just a closing bracket

WordPress does not require the closing PHP tag.

Last updated: