Header ("Location :")

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.