Warning: Cannot modify header information - headers already sent by

warning cannot modify header information - headers already sent by pluggable.php on line 1216
warning cannot modify header information - headers already sent by (output started at /home/content
warning cannot modify header information - headers already sent by magento 2
warning cannot modify header information - headers already sent by 000webhost
cannot modify header information - headers already sent by stackoverflow
warning: cannot modify header information - headers already sent by pluggable php on line 1121
drupal warning: cannot modify header information - headers already sent by
0 warning cannot modify header information - headers already sent by

Hi there I have seen similar problems on the net about this issue but the resolutions I have tried have not worked.

i'm developing a word-press site for a client I have done this before without issue. However, this time when I uploaded the template to my test server for the clients viewing I encountered these errors.

Warning: Cannot modify header information - headers already sent by (output started at /homepages/0/d682858018/htdocs/clickandbuilds/test/wp-includes/option.php:1) in /homepages/0/d682858018/htdocs/clickandbuilds/test/wp-includes/option.php on line 808

Warning: Cannot modify header information - headers already sent by (output started at /homepages/0/d682858018/htdocs/clickandbuilds/test/wp-includes/option.php:1) in /homepages/0/d682858018/htdocs/clickandbuilds/test/wp-includes/option.php on line 809

I have gone to the file and the lines it is referring to are ;

    // The cookie is not set in the current browser or the saved value is newer.
$secure = ( 'https' === parse_url( admin_url(), PHP_URL_SCHEME ) );
setcookie( 'wp-settings-' . $user_id, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure );
setcookie( 'wp-settings-time-' . $user_id, time(), time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure );
$_COOKIE['wp-settings-' . $user_id] = $settings;

Would appreciate some guidance as to what is causing the error and how to fix it.

Things I have tried;

  • *eliminating white space
  • *removing ?>
  • *combing through code in function.php and removing whitespace.
  • *reinstalling wordpress.

Some people have marked this question as similar to another question but as I have mentioned this is different it's something to do with the template. It works fine locally

try to upload template via file manager and just activate it in wp-admin.

Warning: Cannot Modify Header Information – Header Already Sent By, How does one prevent the following warning warning Cannot modify header information headers already sent and why does it occur in the first place? The error states “Warning: Cannot modify header information – headers already sent by …” with details of the file and line of code with the error. If the developer is unaware of the cause of this error, he may spend hours to get the issue resolved. Understanding why the error occurs will help you find the solution.

Found the issue when I actually viewed the code in a separate editor it highlighter a space before the opening

Thanks for everyones comments.

Warning: "Headers already sent" or "Cannot modify header , What causes the headers already sent error when using the header () function? Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more How Do I fix “Warning: Cannot modify header information - headers already sent by (output started at..” in PHP [duplicate]

for me this error was in my Prestashop site(v 1.6.0.6) homepage and solved by lowering site php version from 5.6 to 5.3 in cpanel => MultiPHP Manager section.

so if you prefer more detail and manual editing, check .htaccess file and add following line to it

AddHandler application/x-httpd-php53.php

by having a blank line at the end of *. inc files. Cannot modify header information – headers already sent in (file location). To sum this error up – It is basically telling you that you cannot output data before you attempt to modify header information.

Warning: Cannot Modify Header Information – Header Already Sent By. This PHP header error results from extra empty spaces that are not suppose to be within your files. You could have unknowingly created them when you are modifying WordPress or your Theme files. Question: Cannot modify header information - headers already sent by Answer: This problem is actually listed in the "common problems" section of the installation instructions, but many users only seem to run into it when they start configuring their site after the initial setup.

If you're getting the "Cannot modify header information" error, there's a Warning​: Cannot modify header information – headers already sent  Now, even if part of your theme starts to send input to the browser, PHP won't send that text until the page is fully loaded, which allows WordPress to redirect users, if necessary, as part of its own logic.

Warning: Cannot modify header information - headers already sent by (output started at /some/file.php:12) in /some/file.php on line 23. The lines mentioned in  Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\index.php:11) in C:\Program Files\xampp\htdocs\login.php on line 8

Comments
  • check if you are using print or echo
  • Possible duplicate of How to fix "Headers already sent" error in PHP
  • Print or Echo in the header.php file ? or the options.php file. forgive me i need some context around your sentence.
  • Through some more research, I found out it must be something to do with my template. When I use one of the default themes it disappears. The Strange thing is this does not happen locally? What could be causing the issue?
  • You need to wrap your code in a function and hook to init function so that headers won't be sent when your code executes.