PHP: Cannot Modify Header Information

I downloaded a very cool theme for this blog and luckily, I successfully installed it in my local instance of WordPress. Satisfying the OC in me, I immediately do some minor twicking to further personalize my page. I tested the page’s comment engine, posting, plugin and widget capabilities but was repeatedly bombarded with this error every time I click a button that causes the page to reload:

Warning: Cannot modify header information - headers already sent by (output started at / my_site/wp-content/themes/new_theme/functions.php:2) in /my_site /wp-includes/pluggable.php on line 694

Having no professional experience in php, my first instinct is to google on the topic and I came across this forum post:

mattsiegman: it will break if you have any space before your <?

The thread suggested different solutions but I tried the simplest one. I opened my functions.php file and found this:

<?php
if ( function_exists(‘register_sidebar’) )
{
    register_sidebar(array(
        ‘before_widget’ => ‘<li id="%1$s" class="widget %2$s">’,
        ‘after_widget’ => ‘</li>’,
        ‘before_title’ => ‘<h2 class="widgettitle">’,
        ‘after_title’ => ‘</h2>’,

I have a space (linebreak) on my first line, I deleted it, saved and refreshed my browser. Voila! The error was gone. See how complicated problems can be solved by simple solutions?

1 Response to “PHP: Cannot Modify Header Information”


  1. 1 bleue

    Haha! That’s the catch in development. A very complex problem involving business requirements can sometimes be solved by a very simple solution. Kakainspire gumawa blog like this one. hmmmmm….

    And nice blog name, hehehe! Let me translate it in java String.valueOf(Me.Thoughts) or in VB CStr(Me.Thoughts) or in Oracle SQL TO_CHAR(ME.THOUGHTS)! HEhehe! … so many variations…

Leave a Reply