Tag Archive: php ansi encoding wp plugin

Headers Already Sent Error in WordPress Plugin Activiation

February 14, 2012

Before I could even start writing plugins for WP, I was experiencing errors. This was the biggest message I got upon activation :

The plugin generated # characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

At the top of the page, it was even worse. You could see errors accumulating before the page was even finished loading –

Warning: Cannot modify header information – headers already sent by (output started at /homepages/37/d354510180/htdocs/BLAH/BLAH/BLAHplugin.php:1) in /homepages/37/d354510180/htdocs/BLAH/BLAH/BLAH/wp-includes/functions.php on line 862

After some Googling, people claimed it was the whitespace at the beginning or end of my PHP file. I cleared all that up, still had a problem. I started messing around with encoding instead.

UTF-8 WITH BOM, and UTF-8 WITHOUT BOM both caused errors upon activation. Finally, I switched to ANSI in “Notepad++” and that resolved it. No issues from there on out.

There are also other methods of adjustment, including your uploading process. I used Filezilla and this can be found under Transfer > Transfer Type.

SOMETHING is putting extra white space in your plugin PHP file… you just need to find out what. Hope this helps.