The plugin generated x characters of unexpected output

I’m developing WordPress plugin and do get this error on activation:

Error : The plugin generated 4 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.

Read More

The snippet below illustrates how my plugin looks like:

<?php
/*
Plugin Name: XXXXX
Plugin URI: XXXXX
Description: XXXXX
Version: 1.0
Author: XXXXX
Author URI: XXXXX
License: GNU
*/

echo"test";
?>

What is causing this error and how can I resolve it?

Related posts

1 comment

  1. A couple of issues:

    1. Your plugin shouldn’t directly echo anything. Instead, add your echo to a WordPress hook if you need to test things. For example, replace your echo "test"; with something like:

      add_action( 'init', function() { echo 'test'; });
      
    2. It’s recommended to remove the closing ?> tag, to avoid “Headers already sent” notifications.

Comments are closed.