I encountered this error today while testing the following code:
An error occurred:
After looking at some online methods, I didn’t find a solution. Finally, I configured output_buffering in php.ini to default to 4096 and no longer encountered this error:
output_buffering setting instructions:
Off: Indicates turning off PHP output caching
On: Turn on infinite output buffer
4096: Open output cache with size 4096Byte
By default, php buffer is enabled, and the default value of the buffer is 4096, which is 4kb. You can find the output_buffering configuration in the php.ini configuration file. When echo, print, etc. output user data, the output data will be written to php output_buffering. Until output_buffering is full, the data will be sent to the browser through tcp. show. You can also manually activate the php output_buffering mechanism through ob_start(), so that even if the output exceeds 4kb of data, the data is not actually handed over to tcp and passed to the browser, because ob_start() sets the php buffer space to be large enough. The data will not be sent to the client browser until the end of the script or the ob_end_flush function is called.
For a detailed introduction to output_buffering, please refer to:
http://www.bkjia.com/article/55707.htm
Supplement: Of course you can also solve this problem by removing the BOM. It is recommended to encode in UTF-8 BOM-free format. Thanks @ihipop children’s shoes
Regarding the BOM, simply speaking, the software uses the BOM to identify whether the file is UTF-8 encoded. In early versions of Firefox, extensions could not have BOMs, but versions after Firefox 1.5 have begun to support BOMs. Now I discovered that PHP does not support BOM either. PHP did not consider the BOM issue when it was designed, which means that it will not ignore the three characters of the BOM at the beginning of the UTF-8 encoded file.
Another trouble was mentioned: "Limited by the COOKIE sending mechanism, in files that already have BOM at the beginning of these files, the COOKIE cannot be sent (because PHP has already sent the file header before the COOKIE is sent), so logging in and The logout function is invalid. All functions that rely on COOKIE and SESSION are invalid. "This should be the reason why a blank page appears in the WordPress background, because any executed file contains a BOM, and these three characters will be sent. Functions that rely on cookies and sessions are invalid, so you may also encounter the following errors:
Open php.ini and set output_buffering to on. Restart appache, OK.
1. Sessionstart generally does not need to be called, and the server automatically handles it.
2. The two pieces of script code should be placed in the appropriate positions in