Home >Backend Development >PHP Tutorial >The impact of bom_PHP tutorial
The following error occurred when setting cookie. Cannot modify header information - headers already sent by .... This error is very common. If any text content is output before setcookie, the above error message will appear. Since several files are required at the top of the page, it is very troublesome to check them line by line. Therefore, I added: PLAIN TEXT PLAIN TEXT Then I opened the source file with vim and found that vim had the bomb option turned on. I suspected that a hidden string was added to the code, so I closed it: set nobomb Problem solved. What does BOM mean? Author: volcano Published on February 28, 2008 at 8:16 pm Copyright information: You can reprint at will. When reprinting, please be sure to indicate the original source and author information of the article and this statement in the form of a hyperlink Permanent link - http://www.ooso.net/index.php/archives/378
PHP:
ob_start();
Add code before setcookie:
PHP:
ob_get_clean();
This is to get the content output by the page before setcookie. After the page is run, an empty string is displayed and output, that is, there is no output before setcookie.
BOM is the abbreviation of "Byte Order Mark", which is used to mark the encoding of files. Not all text editing tools recognize BOM tags