Today's Question:  What are you most afraid of as a programmer?        GIVE A SHOUT

Technical Article => Web =>  PHP

Handle ”cannot modify header information – headers already sent by”

  Peter      2012-11-17 08:45:22      9,027    2    0

Man PHP developers should encounter ”Warning: Cannot modify header information – headers already sent by ….” error before when executing a PHP script.

Here are some solutions to this error.

1. Blank line

Check whether there is any blank line after , especially in the files which are used in include() and require(0, some problems are caused by blank lines.

2. Add exit() after head()

header (“Location: xxx”);
exit();

3. Use output cache

<?php ob_start(); ?>
… HTML codes …
<?php
… PHP codes …
header (“Location: ….”);
ob_end_flush();
?>

If you have any other solution to this error. You can share with us by post your solution to the comment area.

Source :http://blog.vip7758.com/63.html

HEADER SENT PHP ERROR HANDLE

  SAVE AS PDF   MARK AS READ   MARK AS IMPORTANT

Share on Facebook  Share on Twitter  Share on Google+  Share on Weibo  Share on Reddit  Share on Digg  Share on Tumblr    Delicious

  RELATED


  2 COMMENTS


leo [Reply]@ 2013-06-27 19:45:48

The end of the first three examples to write a sh ();?> Right?

----From google translate

Night walker [Reply]@ 2013-06-27 21:33:27

Hi, leo. Thank you for pointing out the error. We have modified the code.


  WRITE ARTICLE

Difference between man and woman

By rookie