<? Phpif ($ _ SESSION ["login"]! = 'Yes') {// ob_start (); // echo "<script language = javascript> alert ('Log On! '); </Script> "; // sleep (3); header (" Location: http ://". $ _ SERVER ['HTTP _ host']. "/my-login.php"); // ob_end_flush () ;}?>
Cannot modify header information-headers already sent by (output started...) is always reported ...)....
The following are some other reasons and solutions for the Cannot modify header information-headers already sent by error.
Method 1:
There are some restrictions on the use of cookies in PHP.
1. Use setcookie before the 2. You cannot use echo to input content before using setcookie.
3. The cookie will not appear until the webpage is loaded
4. setcookie is sent only when it is placed in any data output browser.
.....
Due to the above restrictions, when using the setcookie () function, you will encounter "Undefined index", "Cannot modify header information-headers already sent "... The solution is to generate a cookie before the output content. You can add the function ob_start () at the top of the program ();
Ob_start: Open the output buffer.
Function Format: void ob_start (void)
Note: When the buffer zone is activated, all non-file header information from the PHP program is not sent, but stored in the internal buffer zone. To output the buffer content, you can use ob_end_flush () or flush () to output the buffer content.
Method 2:
Solve Warning: Cannot modify header information-headers already sent ......
A few days ago, I installed a php Big Head sticker system test and found the error Warning: Cannot modify header information-headers already sent ......
This problem still occurs when openads is installed again today. Angry. After searching for the Internet for a long time, some people say they want to write ob_start () at the beginning of the file ();
Method 3:
It is found that only this method works: Open php. ini and set output_buffering to on. Restart appache, OK. It seems that this is the solution.
Note:
If you use UTF-8 encoding, be sure to remove the BOM in the UTF-8, this is because the UTF-8 encoding file contains the bom, and php4, 5 are not supported bom. Remove bom and use Notepad ++ to open the conversion. Remember, remember, remember! (This problem has plagued me for a long time .)
Use PHP's ob_start (); to control the cache URL of your browser