PHP completely eliminate Warning:cannot add header information-headers already sent in ...
Solution:
1) For those who have permission to edit php.ini
Open the php.ini file (you are better than I know where your php.ini is) and find
output_buffering = change to On or any number. If it is IIS6, please change to ON, otherwise your PHP efficiency will be very slow.
2) Use virtual host, can't edit php.ini, how to do?
Simple:
Create a. htaccess file in your spatial root directory with the following content:
AllowOverride All
Php_flag output_buffering on
The unfortunate situation is: or not? All pages are not displayed?
Well, you can call and scold a space quotient, and then let him give you the Apache. htaccess allowoverride Open
3) Resolve in PHP file
Ob_start ()
Enable the output buffering mechanism. Output buffering supports multiple levels--for example, the Ob_start () function can be called multiple times.
Ob_end_flush ()
Send output buffer (out buffering) and disable the output buffering mechanism.
Ob_end_clean ()
Clears output buffer but does not send, and disables output buffering.
Ob_get_contents ()
Returns the current output buffer as a string. Allows you to handle any output that the script emits.
Principle:
When Output_buffering is enabled, PHP does not send an HTTP header when the script sends the output. Instead, it imports this output through a pipeline (pipe) into a dynamically increasing cache (only used in PHP 4.0, which has a centralized output mechanism). you can still modify/add a header, or set a cookie because the header is not actually sent . When all the scripts are terminated, PHP automatically sends the HTTP header to the browser, and then sends the contents of the output buffer.
Reprint please must indicate from: www.phpv.net