The following error occurs when setting cookies.
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 there are several files required at the top of the page, it is very troublesome to check them line by line. Therefore, I added:
PLAIN TEXT
at the top of the page.
PHP:
ob_start();
Add code before setcookie:
PLAIN TEXT
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.
Then I opened the source file with vim, and found that vim had the bomb option enabled. I suspected that a hidden string was added to the code, so I closed it:
set nobomb
problem was solved.
What does BOM mean?
BOM is the abbreviation of "Byte Order Mark", which is used to mark the encoding of files. Not all text editing tools can recognize BOM tags
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 in the form of a hyperlink.
Permanent link to
this statement
- http://www.ooso.net/index.php/archives/378