How to Get Rid of Plugin Generated Unexpected Output During Activation Error

Most of the WordPress developers mess with “plugin generated xx characters of unexpected output during activation” error while plugin development and I faced the same scenario while developing a WordPress plugin some days ago. The error was also included a warning message “headers already sent, problems with syndication feeds or other issues, try deactivating or removing this plugin”.

When I searched for the error in Google, I got some solutions from many sources around the web and I am going to share them with you. So let’s get started with rectifying plugin generated unexpected output during activation error.

plugin generated unexpected output during activation

Also read:

How to Avoid Plugin Generated Unexpected Output During Activation Error?

Check for PHP Starting and Ending Tags

Make sure your PHP code starts with <?php and ends with ?> because this is the main cause of error while WordPress plugin development. When it comes to my plugin error, I had started PHP tag with <? Instead of <?php in hurry which was causing the error. I noticed this incorrect PHP starting tag when I started reviewing the code to debug it and corrected it by replacing it with <?php. Developers should also avoid white spaces before and after the closing PHP tags.

Make Sure to Use Simple Text Editor

Always use simple text editor to code wordpress plugin and wordpress themes, remember, modifying your code with MS Word or other document editors can spoil the whole game as they change the encoding of the file which results in unexpected output during plugin activation. Windows Notepad, Notepad++, Sublime Text 2, TextWrangler and WebTide Editor are some free text editors for Windows, Linux and Mac operating systems.

Work With WordPress Debug Mode Turned On

It is good practice to start wordpress development with debug mode turned on, turning debug mode on shows the warning messages on top of your website that makes it easy to find out the errors and rectify them. Here is the step by step guide to turn on wordpress debug mode.

How to Turn on WordPress Debug Mode

You can switch your wordpress to debug mode by modifying a PHP file located in the root folder of your wordpress installation-

  1. Go to the wordpress root directory, if you are using XAMP localhost then the URL would be something like “C:\xampp\htdocs\dummyWP”
  2. Open wp-config.php with notepad or with your favorite text editor tool
  3. Scroll down a bit and you get define(‘WP_DEBUG’, false); line of code
  4. Now replace “false” with “true” and save the file
  5. That’s it, wordpress debug mode will be turned on.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.