How to handle “The plugin generated x characters of unexpected output” errors in WordPress

Some errors are hard to trace, especially when no line of error or function/variable is

If you ever ecounter “The plugin generated x characters of unexpected output” in your WordPress plugin development, a simple solution is to include the following line in your function/method:

file_put_contents(__DIR__ . '/activation_log.txt', ob_get_contents());

This will write any output to a file in the current directory where the file containing the function/method resides.

Advertisements

Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s