In fact, it is not a mistake. It is a warning(Warning).
This is done when your browser requests the web server. With the response from the web server. It gives you a response header(header). This header contains information about page encoding, page size, cache duration time, last update time, and everything relevant about a web page to a browser.
When you read "headers already sent" means the server has already sent the header and AFTER this submission you are trying to change some information that should be sent in the header.
But if you’re not manipulating anything that comes in header. You have done nothing and are getting this error.
In PHP the header starts uploading as soon as you enter the first HTML character. Either outside of PHP or inside PHP code with an echo or print().
<?php
$numero_1 = 5;
echo $numero_1;
?>
Everything outside of PHP code is HTML, a space on line 1 before the opening of PHP code would be the reason for a response to the client. Any function, session, cookie would cause error.
To fix this warning. You would have to put all the code that works with Session, cookie, redirects, etc... before any HTML character. No trying to set/create a cookie after sending a "Hello world" message to your browser.
If you need to set/create a cookie before sending a "Hello world" message or anything, rethink what you are doing.
It would be better if you showed the code, no? Incidentally, the SOPT deserves a version of How to fix "Headers already sent" error in PHP, these mistakes will drip day in and day out for a lot of time.
– brasofilo
@brasofilo My question was purposeful, exactly for this. Good idea to assemble this guide! If no one answer I answer :)
– Ricardo
possible duplicate ?
– rray
@lost, yes. Pity that the title of the other is so little descriptive...
– brasofilo
nothing prevents us editing the title of the other, or prevents?
– Math