源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

PHP页面跳转操作实例分析(header方法)

  • 时间:2022-10-25 22:37 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:PHP页面跳转操作实例分析(header方法)
本文实例分析了PHP页面跳转操作。分享给大家供大家参考,具体如下: [b]跳转[/b] header()为php函数,向浏览器发送指定命令 html:
<meta http-equiv="Refresh" content="3;url=other.php"/>

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

执行header时候,并不是立即结束,而是会把页面执行完毕;在header前面不能有任何输出,若有开启输出缓冲则不提示错误,php.ini->output_buffering = 4096|OFF 提示跳转:
header('Refresh:3,Url=other.php');
echo '3s 后跳转';
//由于只是普通页面展示,提示的样式容易定制
die;

[b]封装的跳转函数:[/b]
/*
 *跳转
 *@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;
}

更多关于PHP相关内容感兴趣的读者可查看本站专题:《[url=http://www.1sucai.cn/Special/495.htm]PHP网络编程技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/348.htm]PHP基本语法入门教程[/url]》、《[url=http://www.1sucai.cn/Special/96.htm]php日期与时间用法总结[/url]》、《[url=http://www.1sucai.cn/Special/43.htm]php面向对象程序设计入门教程[/url]》、《[url=http://www.1sucai.cn/Special/47.htm]php字符串(string)用法总结[/url]》、《[url=http://www.1sucai.cn/Special/84.htm]php+mysql数据库操作入门教程[/url]》及《[url=http://www.1sucai.cn/Special/231.htm]php常见数据库操作技巧汇总[/url]》 希望本文所述对大家PHP程序设计有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部