Header ("Location: blog.my400800.cn
")
As a PHPTurning statement
. In fact, there are several points worth attention in use.
1. No output is required before the header.
However, many times we have output many items before the header. However, if the header is used again, it is obviously incorrect. Here we enable the concept of OB, this stuff means to store the relevant output on the server side and wait for the proper time to output the output, instead of running a sentence like the current one. The header statement can only report an error.
Specific statements include: ob_start ();
Ob_end_clean (); ob_flush ();.........
2.Exit header ("Location: www.my400800.cn") in time
Otherwise, he will continue to execute the command. Although you cannot see the corresponding data on the browser side, if you perform packet capture analysis, you will see that the following statement is also being executed. It is also delivered to the browser client, but it is not executed as HTML by the browser (the Browser executes the header and performs the redirection operation ).
So,The standard method of use is
:
Ob_start ();
........
If (something ){
Ob_end_clean ();
Header ("Location: www.my400800.cn ");
Exit;
Else {
..........
Ob_flush (); // can be omitted