PHP 标头重定向 [英] Php header redirect

查看:58
本文介绍了PHP 标头重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标题重定向,它可以工作,但是它似乎在 ied 时运行了我的代码两次,而不是它只是重定向然后执行代码.似乎先完成所有代码,然后重定向,然后再完成所有代码.我检查了这一点,因为我在会话中增加了一个整数,并且它在实际到达目的地时出现,即使增加会话的代码是在我的标头重定向之后.

I have a header redirect in place which works however it seems to run through my code twice when ied rather it just redirect and then do the code. It seems to do all the code and then redirect and then do all the code. Ive checked this because ive incremented an integer in a session and it comes up to when it actually gets to its destination even though the code to increment the session is AFTER my header redirect.

这是为什么.

推荐答案

没有一些代码很难说,但这是我见过很多的:如果您调用标头,您的代码不会不会停止.所以标头会向浏览器发送一些内容,但代码会继续运行.

Hard to say without some code, but this is one i've seen a lot: If you call the header, your code does not stop. So the header sents some stuff to the browser, but the code will keep on running.

如果执行应该在您的标头之后停止,请显式调用 dieexit

If the execution should stop after your header, explicitly call die or exit

这篇关于PHP 标头重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆