KNOWNHOST WIKI

User Tools

Site Tools


developmental:what-is-the-headers-already-sent-php-error

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
developmental:what-is-the-headers-already-sent-php-error [2016/10/26 10:52]
mscherf [Possible solution] added link
developmental:what-is-the-headers-already-sent-php-error [2020/05/13 13:36] (current)
Karson N.
Line 4: Line 4:
 <​code>​Warning:​ Cannot modify header information - headers already sent by (output started at /​some/​file.php:​12) in /​some/​file.php on line 23</​code>​ <​code>​Warning:​ Cannot modify header information - headers already sent by (output started at /​some/​file.php:​12) in /​some/​file.php on line 23</​code>​
  
 +\\
 ===== Why does it happen? ===== ===== Why does it happen? =====
 To understand why headers must be sent before output it's necessary to look at a typical HTTP response. PHP scripts mainly generate HTML content, but also pass a set of HTTP/CGI headers to the webserver: To understand why headers must be sent before output it's necessary to look at a typical HTTP response. PHP scripts mainly generate HTML content, but also pass a set of HTTP/CGI headers to the webserver:
Line 14: Line 15:
 When PHP receives the first output (''​print'',​ ''​echo'',​ ''<​html>''​) it will "​flush"​ the collected headers. Afterwards it can send all the output bits it wants. But sending further headers is impossible from then. When PHP receives the first output (''​print'',​ ''​echo'',​ ''<​html>''​) it will "​flush"​ the collected headers. Afterwards it can send all the output bits it wants. But sending further headers is impossible from then.
  
 +\\
 ===== Functions that modify the HTTP header ===== ===== Functions that modify the HTTP header =====
   * header   * header
Line 23: Line 25:
  
  
 +\\
 ===== Possible solution ===== ===== Possible solution =====
 <WRAP center round info 100%> <WRAP center round info 100%>
Line 49: Line 52:
   - DO NOT PUT CODE IN UNNECESSARY CODE BLOCKS, PUT THEM IN A SINGLE PHP BLOCK.   - DO NOT PUT CODE IN UNNECESSARY CODE BLOCKS, PUT THEM IN A SINGLE PHP BLOCK.
  
 +\\
 ===== Referenced and helpful resources ===== ===== Referenced and helpful resources =====
   * [[http://​stackoverflow.com/​questions/​8028957/​how-to-fix-headers-already-sent-error-in-php]]   * [[http://​stackoverflow.com/​questions/​8028957/​how-to-fix-headers-already-sent-error-in-php]]
   * [[http://​php.net/​manual/​en/​function.headers-sent.php]]   * [[http://​php.net/​manual/​en/​function.headers-sent.php]]
   * [[http://​codex.wordpress.org/​FAQ_Troubleshooting#​How_do_I_solve_the_Headers_already_sent_warning_problem.3F]]   * [[http://​codex.wordpress.org/​FAQ_Troubleshooting#​How_do_I_solve_the_Headers_already_sent_warning_problem.3F]]
developmental/what-is-the-headers-already-sent-php-error.txt · Last modified: 2020/05/13 13:36 by Karson N.