This article analyzes the PHP page jump operation with an example. Share it with everyone for your reference, the details are as follows:
Jump
header() is a php function that sends specified commands to the browser
html:
<meta http-equiv="Refresh" content="3;url=other.php"/>
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 output buffering is turned on, no error will be prompted. php.ini->output_buffering = 4096|OFF
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"<meta http-equiv=\"refresh\" content=".$sec.";URL=".$url.">"; echo $info; } die; }
For more PHP page jump operation example analysis (header method) related articles, please pay attention to PHP Chinese website!