Error: Cannot modify header information – headers already sent [duplicate]

I started learning PHP the other day and can’t figure out the error. When I write code

header("Content-type: image/jpeg"); //      

Then PHP says:

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

Who sends the headers (Apatch php or who)? And how do I have full control over the output, or disable auto-sending of headers?


Answer 1, authority 100%

All headers are sent to the browser before the first letter is displayed, so this code that adds a string to the standard headers should not be preceded by any statement that outputs text to the browser, echo, dumps, etc.

there shouldn’t even be a space before the opening <?php – double check


Answer 2, authority 50%

Read this