Explanation of the specific meaning of the PHP page jump function _ PHP Tutorial

Source: Internet
Author: User
For you to explain the specific meaning of the PHP page jump function. PHP itself does not have a fully functional PHP page jump function. maybe the Header function is regarded as one, but it can only be used for the first line of the page. If it is placed at the end of the PHP page

PHP itself does not have a fully functional PHP page jump function. maybe the Header function is regarded as one, but it can only be used for the first line of the page. If it is placed at the end of the PHP page, an error will be reported unless the preceding PHP does not output any characters.

The following three PHP automatic page jump methods are provided: one is to use the Header function, and the other is to use the inherent HTML mark. of course, this method can be applied not only to PHP, but also to ASP ,. net, and Jsp, the third method is to output Javascript, using Js code to achieve PHP page automatic jump purpose, the same, this method is also applicable to other languages than PHP, the corresponding language code is different.

PHP page jump function 1. use HTTP Header information (Header function)

That is, use the php header function. The HEADER function in PHP is used to send control commands that should have been specified by the HTTP protocol to the browser through the WEB server, such as declaring the type of returned information ("Context-type: xxxx/xxxx "), page attributes (" No cache "," Expire "), and so on.
You can use the HTTP header to automatically redirect PHP to another page as follows:

 
 
  1. < ?PHP
  2. $url = czbin.PHP
  3. Header("HTTP/1.1 303 See Other");
  4. Header("Location: $url");
  5. exit;
  6. ?>

Note that "Localtion:" is followed by a space.

PHP page jump function 2. use HTML tags (REFRESH attribute in META)

The HTML tag is the REFRESH tag of META, for example:

 
 
  1. < ?PHP $url = czbin.PHP;?>
  2. < HTML>
  3. < HEAD>
  4. < META HTTP-EQUIV="REFRESH"
    CONTENT="10; URL=< ? echo $url;?>>
  5. < /HEAD>
  6. < BODY>
  7. < /BODY>
  8. < /HTML>

Note: CONTENT = "10 indicates that the jump will take 10 seconds.

PHP page jump function 3. implemented using JAVASCRIPT scripts

Example:

 
 
  1. < ?PHP
  2. $url=czbin.PHP;
  3. echo "< !--< SCRIPT LANGUAGE="JavaScript">";
  4. echo "location.href='$url'";
  5. echo "< /SCRIPT>-->";
  6. ?>


PHP does not have a fully functional PHP page jump function. maybe the Header function is regarded as one, but it can only be used for the first line of the page. If it is placed at the end of the PHP page ,...

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.