U3F1ZWV6ZTc5OTgzNDMxMzE1MzJfRnJlZTUwNDYwNDY0NzA3Nzc=

Headers already sent (Also applies to [FPHP]session_start[/FPHP] failure)

Headers already sent ,php problems header


Question:
Headers already sent (Also applies to [FPHP]session_start[/FPHP] failure)
Symptom: Error message declares headers already sent, when attempting to use the [FPHP]header[/FPHP] or [FPHP]session_start[/FPHP] function.
Cause: Whitespace at top of script.

Solution: 
header
(PHP 4, PHP 5, PHP 7)

header - Sends a raw HTTP header

Description 
header (string $ header [, bool $ replace = TRUE [, int $ http_response_code]]): void
header () allows you to specify the HTTP string header when sending HTML files. Refer to »HTTP / 1.1 Specification for more information on HTTP headers.


Never forget that header () must be called before any content is sent, either by usual HTML lines in the file, or by PHP displays. A very common error is to read a file with include or require, and leave blank spaces or lines, which will produce a display before the header () function is called. The same problem exists with standard PHP / HTML files.

Make sure that the < of your first <?php is line 1, character 1. There can be no whitespace, no blank line, anything, prior to that PHP block opening, or the HTML headers are considered sent. The [FPHP]header[/FPHP] function can only be used once per execution.



if you want to improve the solution
comment to help the community
Comments
No comments
Post a Comment

Post a Comment

NameEmailMessage