If you see this warning when you execute a PHP program: "Warning:cannot Modify header Information-headers already sent by ..."
Few notes based on the following user posts:
The following workarounds are available:
1. Blank lines (empty line):
Make sure no blank line after of the calling PHP scrīpt.
Check that there are no blank lines behind, especially the include or require files. Many problems are caused by these blank lines.
2. Use Exit statement (to be resolved with exit):
Use exit after header statement seems to help some people
Add exit () after the header;
Header ("location:xxx");
Exit ();
3a. Use JAVASCRĪPT (to be resolved with javascrīpt):
Self.location (file.php); >
Since It s a scrīpt, it won T modify the header until execution of JAVASCRĪPT.
You can use JAVASCRĪPT instead of headers. It is also important to note that using this approach requires a browser to support JAVASCRĪPT.
3b. Use output buffering (to be resolved with the export cache):
... HTML codes ...
... PHP codes ...
Header ("Location: ....");
Ob_end_flush ();
?>
Another article
Ob_start ();
Setcookie ("username", "Song Yan Bin", Time () +3600);
echo "The username is:". $HTTP _cookie_vars["username"]. " n ";
echo "The username is:". $_cookie["username"]. " n ";
Print_r ($_cookie);
?>
Warning:cannot Modify header Information-headers already sent by error reason
I added the header to the PHP program,
Header ("Cache-control:no-cache,must-revalidate");
After the page appears above the error, read n data also has no results. Today occasionally found that the original is my php.ini inside the configuration out of the problem, found in c:windows php.ini file
The output_buffering default is off.
Tips, there is a better solution is to php.ini and then set output_buffering to On [...] There would be no such problem.
http://www.bkjia.com/PHPjc/632112.html www.bkjia.com true http://www.bkjia.com/PHPjc/632112.html techarticle If you see this warning when you execute a PHP program: Warning:cannot Modify header information-headers already sent by .... Few notes based on the following user posts: There are several solutions ...