Home>Article>Backend Development> The header method in php realizes page jump

The header method in php realizes page jump

黄舟
黄舟 Original
2017-11-10 17:34:00 6342browse

In the previous article, we introduced the headerfunctionin php, as well as the definition of header. There are many ways to use header in php. Today we will introduce to you the header method in php to achieve page jump. Transfer cases,

This article analyzes the PHP page jump operation with examples. Share it with everyone for your reference, the details are as follows:

Jump

header() isphp function, which is sent to the browser Specify the command

html:

Jump immediately:

header('Location:other.php'); //file_put_contents('bee.txt','execute'); die;

When executing the header, it does not end immediately, but The page will be executed; there cannot be any output in front of the header. If the output buffering is turned on, no error will be prompted. php.ini->output_buffering = 4096|OFF

will prompt jump:

header('Refresh:3,Url=other.php'); echo '3s 后跳转'; //由于只是普通页面展示,提示的样式容易定制 die;

Encapsulated jump function:

/* *跳转 *@param $url 目标地址 *@param $info 提示信息 *@param $sec 等待时间 *return void */ function jump($url,$info=null,$sec=3) { if(is_null($info)){ header("Location:$url"); }else{ // header("Refersh:$sec;URL=$url"); echo""; echo $info; } die; }

Summary:

PHP page Jump operation, combined with examples, compares and analyzes the related operation skills andNotesof HTML jumps and PHP header method jumps, and provides a jump encapsulation function for your reference!

Related recommendations:

Analysis of the role of the header function in php


Detailed explanation of header definition in php


## Analysis and solutions to the causes of PHP Header failure


The above is the detailed content of The header method in php realizes page jump. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn