WordPress Plugin Development – Headers Already Sent Message

I’m developing WordPress plugins. When I activate my plugin, I’m getting the following message:

The plugin generated 293 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.

The plugin is working very well but I don’t know why I’m getting this message. My plugin is : http://wordpress.org/extend/plugins/facebook-send-like-button/

10

My guess is you get a PHP error, which generates output before the headers are sent. If you have E_NOTICE enabled, calling $_POST['foo'] may generate a “Notice: undefined variable” error if that variable is not set.

Best practice: never assume anything about GET, POST, COOKIE and REQUEST variables. Always check first using isset() or empty().

if ( isset( $_POST['foo'] ) ) {
    $foo = (string) $_POST['foo'];
    // apply more sanitizations here if needed
}

Leave a Comment