Php completely eliminates warning: Cannotaddheaderinformation-headersalreadysentin ...... solution: 1) applicable to PHP with permission to edit. INI people open php. ini file (you should be clear about your php. ini), change output_buffering to on or any number. if it is II php, completely eliminate warning: Cannot add header information-headers already sent in ......
Solution:
1) applicable to persons with permissions to edit PHP. INI
Open the php. ini file (you should know where your php. ini is) and find
Output_buffering = changed to on or any number. if it is IIS6, change it to ON. Otherwise, your PHP efficiency will be very slow.
2) when using a VM, you cannot edit PHP. INI. what should I do?
Simple:
Create a. htaccess file under the root directory of your space. the content is as follows:
AllowOverride All
PHP_FLAG output_buffering On
Unfortunately: or not? Cannot all webpages be displayed?
Then, you can call a space provider and ask him to open apache. htaccess AllowOverride.
3) solve the problem in the PHP file
Ob_start ()
Enable the output buffering mechanism. Output buffering supports multiple levels-for example, you can call the ob_start () function multiple times.
Ob_end_flush ()
Sends the output buffer and disables the output buffering mechanism.
Ob_end_clean ()
Clear the output buffer but not send it, and disable output buffering.
Ob_get_contents ()
Returns the current output buffer as a string. Allows you to process any output from the script.
Principle:
When output_buffering is enabled, PHP does not send HTTP headers when the script sends the output. Instead, it inputs this output to the dynamically added cache through the pipeline (pipe) (which can only be used in PHP 4.0 and has a centralized output mechanism ). You can still modify/add the header or set the cookie because the header is not actually sent. When all scripts are terminated, PHP automatically sends the HTTP header to the browser, and then sends the content in the output buffer.
For reprinting, please note that the source is www.phpv.net.