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