PHP Header method to implement the page jump

Source: Internet
Author: User
In the previous article, we introduced the header function in PHP, as well as the definition of header, there are many ways to use the header in PHP, today we introduce the header method in PHP to achieve page jump case,

This article analyzes the PHP page jump operation. Share to everyone for your reference, as follows:

Jump

Header () is a PHP function that sends the specified command to the browser

Html:

<meta http-equiv= "Refresh" content= "3;url=other.php"/>

Jump Now:

Header (' Location:other.php ');//file_put_contents (' Bee.txt ', ' execute ');d ie;

When the header is executed, it does not end immediately, but the page is executed, no output is allowed in front of the header, and no error is indicated if an output buffer is turned on, php.ini->output_buffering = 4096| OFF

Prompt to jump:

Header (' refresh:3,url=other.php '); Echo ' 3s after jump ';//Because just plain page display, the style of the hint is easy to customize die;

The encapsulated jump function:

/* * Jump * @param $url Target address * @param $info tips * @param $sec wait time *return void*/function jump ($url, $info =null, $sec =3) {if (is_n Ull ($info)) {  header ("Location: $url");} else{  //Header ("Refersh: $sec; Url= $url ");  echo "<meta http-equiv=\" refresh\ "content=". $sec. "; Url= ". $url." > ";  Echo $info; } die;}

Summarize:

PHP page jump operation, combined with examples of the form of the HTML jump and PHP using the header method to jump the relevant operational skills and considerations, and give a jump package function for everyone to reference!

Related recommendations:

The function analysis of header function in PHP


A detailed description of header headers in PHP


The reason analysis and solution of PHP header invalidation

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.