This question has already been answered:

I started learning PHP the other day and can't understand the error. When i write code

header("Content-type: image/jpeg"); // и вообще пытаюсь послать любой заголовок 

PHP says:

Warning: Cannot modify header information - headers already sent by // my script on the first line

Tell me, who sends headers (Apatch php or who)? And how do I completely control the output or disable the automatic sending of headers?

Marked as a duplicate by participants of ReinRaus , AK , Vadim Ovchinnikov , user194374, pavel Jan 6 'at 11:29 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • 3
    The question is caused by the complete lack of understanding of HTTP - cy6erGn0m
  • One more question. I'm sorry for asking; but why with windows-1251 encoding (this is standard in denwer) everything works, and with utf-8 encoding (I wanted to use it in php.ini and in httpconfig or whatever - in short, utf-8 has always pointed out everywhere) mistake; help (i'm so sick of these headers :(). - Rules

2 answers 2

Read this

  • Thanks now for PHP I will look for answers there - Rules

All headers are sent to the browser before displaying the first letter, so before this code, which adds a line to the standard headers, there should not be a single operator that displays text to the browser, echo, dumps, and so on.

there should not even be a space before the opening <? php - recheck

  • I use UTF-8 (WithoutBOM) and you will be happy! ) - kemerov4anin 1:14 pm
  • And how is this WithoutBOM after all to my BOM my Browser Object Model? - Rules
  • one
    In this context, the BOM is [Byte Order Mark] [1]. [1]: - Ilya Pirogov